; CTOS III 1.0
;
; COPYRIGHT  1986, 1987, 1988, 1989, 1990 CONVERGENT TECHNOLOGIES, INC. ALL 
; RIGHTS RESERVED
;
; COPYRIGHT  1980, 1989, 1990, 1991, 1992  UNISYS CORPORATION.
; ALL RIGHTS RESERVED.
; UNISYS PROPRIETARY
;
; THIS PROGRAM IS FURNISHED UNDER A LICENSE RESTRICTING ITS USE SOLELY FOR THE
; OPERATION OF A DESIGNATED COMPUTER FOR A PARTICULAR PURPOSE, AND MAY NOT BE 
; COPIED OR OTHERWISE USED WITHOUT THE PRIOR WRITTEN CONSENT OF CONVERGENT 
; TECHNOLOGIES, INC.  TITLE TO AND OWNERSHIP OF THE PROGRAM, INCLUDING ITS 
; SOURCE CODE, SHALL AT ALL TIMES REMAIN IN CONVERGENT TECHNOLOGIES.  
;
;
;	2884, 4:20 pm.  Vinay  added definitions for multibus
;					  adapter data structure space.
;					  Flag is nAdapters, default 1.
;	11086 JA Merge MF
;	2686 JA remove rgPTBuffers
;	3386 JM Swap Fabs
;	31786 MS add sarCurrent to GraphicsInfo
;	31986 MS add userNumVdm to GraphicsInfo
;	32186 JM fLfsToMaster
;	41586 DR CTOSp and fProtected
;	42586 FW NewGen support.
;	51686 JM sbSwapFileFirst configurable
;	52186 JM vfForkUser
;	52786 JM rgCannotOpenSwapFile
;	53186 JA removed vfForkUser
;	61186 JM COED dcbSeg
;
;	82586 JA FS version
;	92386 DR CTOS II 2.0 merge
;	11386 RLM add orgClusterTerm array
;	12186 JA add rgModDesc, iModDescMax, macro XbusWindowSize
;		also qbAllocateMax
;	12986 JA remove iobuf
;	1886 JA DisplayConfig.run.
;	12287 JA cSegAllocateMax
;	3987 KEB changed version to 11.1
;	3587 JM orgAsib in SysConfigBlock
;	3687 JM add UBuf segment
;	31387 KEB added OEMn.run to execute before sysinit.run
;	32487 MDE,JM add OEMSeg
;   5887  RLM configure timeout counters for master os's.
;	51387 FVW increase maxMedInterruptType by 1 to prevent intSwTbl from 
;               clobbering the XbusIdtable which follows it. (for 2.1)
;	81187 FVW Make sure wVerBuff is on an even word boundary.
;	101587 JA add rgsgAsib, remove rgAsib,rgArib, all tibs.
;	102787 JM RequestNoRemoteTermination macro.
;	111787 JA public userNumNetMinMax.
;	122187 SAR unconditionally allocate wVerBuff space (512 bytes)
;	122187 SAR added cDiskLogThreshold
;	12388  JA  merge with Srp 1.4 
	;	52887 JA rgTermTable
	;	81387 JM statistics for fabs
	;	82687 JMJA rgTermTable biggered for Net users.
	;	93087 JA public userNumNetMinMax for Srp
;	12588  JA  add pStat,pDiskStat,pCdt for all MF
;	2188   JA  Remove fCheckRequestBlockConsistency to kernel. Add fSrpUp.
;	2288   JA  Public rgUserWaitCount, f386.
;	2488   JA  fProtected public.
;	2888   JA  cpuType public, and in Config.  nSwapFabs default 0.
;	21588  JA  more Srp stuff public for WS.
;	21688  JA  remove cpuType, fix FS publics.
;	22288  JA  rgbBufLeds sysgenable size.
;	22588  JA  rgExchReal contains bytes for Srp too.
;	22988  JM add rgUSeg stuff
;	32188  JA remove netrouting; add iMySlot.
;	040588 JM change macro XbusWindowSize to DefineXbusModule, add fMode3
;				param.
;	040588  DR  add pRgSgLdt  for sgLDT to user num mapping
;	040588  DR  add pRgSwapMode  per partition swap modes
;	041388  RLM make xblockheader 32 bytes
;	042088  JM  remove rgUcb, rgoUcb  now created in own segment during init.
;	050288 MTR  add sSwapMap, sMemMapexport *Map
;	071588  JA  pFPMasterMountTable made into pa
;	080588  JA  386 srp
;	082388  BF  OS process names
;	082288  JA  InterruptMask macro.
;	082488  JM  solder gh list together correctly.
;	090688  JA  mask8259A,cascade8259A are words.
;	090788  MTR maps out of DGroup  dynamically allocated,
;                 SCB oRgOUcbObsolete<oPRgOUcb, oRgOExUcb<oPRgOExUcb
;	092388  MTR sys exch names
;	103188  MTR allocate ucbSeg  exUcbSeg, initialized postboot
;	103188  KH  tyCoprocessor and tyRedirect
;	110988  JAKH mask8259aA, cascade8259A are moved to Data_all.asm
;	111188  AT  added paConfigFile, cbConfigFile, bBoardsNotReady in Cdt,
;				  removed termTable, lineTable, fMasterReady.
;	111788  MTR add DbgGroup (for rgOSProcName, et al)  debl macro
;	111988  JARLM mouseData for MF too.
;	121688  PGJ Entries in 'mptyDevMask' 12 bytes long (new 'cMask' field)
;	018989  RLM use GP SI AND CI for 386 srp.
;	013089  JA  cdt.userNumMax.
;	021689  AT  cPagesMBusWindow.
;	040589  JARLM nTicks = 4.  No more lineHZ.
;	041889  AT  BootDebugToken, BootDumpToken
;	051089  JA  add publics for W blocks.
;	051989  AT  replace fFiller with bDumpCommand in cdt.
;	060589  JMR added userNumChannelE to H for CI for rgcommline
;	060889  JA  add fWashDisable, rgObit to cdt
;	060989  JA  cPagesMBusWindow > cMegabytesOtherBoardMax in prefix file.
;	              add tyXINTR0,tyXINTR1,tyHINTR71,tyXINTR3,tyXINTR4,tyHINTR87.
;	070689  JAY declared WS (pMstrpStnd) publics: sStat, sIccStat, sProcStat,
;                 sDiskStat, sExchStat, pIccStat, pProcStat, pExchStat.
;	072189  AT  fGP, fCI and fSI are always the same for OS.
;	              fNoFileSystem no longer public so it won't get used.
;	              HACK for maxDevMounted so mount table is big enough.
;	072889  AT  Removed BootDebugToken, BootDumpToken.
;	080389  AT  Added nRkvsUsers.
;	081589  AT  userNumNetMinMax initially slot 37.
;	082089  AT  word align paConfigFile, cbConfigFile in CDT
;	082289  JM  obsolete scb.nParDesc, scb.oprgoUcb, scb.oPrgoExUcb;
;	              reimplement scb.bMasterFpCpuId, scb.bMySlot, 
;	              scb.bMasterCpCpuId
;	082289  AT  obsolete bMyLine.  Slight fixes for JM changes above.
;	082489  BF  DbgGroup into OSNamePlace
;	090189  AT  Change of 082089 was lost in merging, reinstated.
;	092789  JA  Add optional UfbSeg, FabSeg.
;	092989  MTR rgSbWsUserName now alloc'd by InitClstr, dummy labels retained
;	09??89  ??? Add rgUpdateResourceName.
;	100589  JAmtr Cdt sDeviceHandle is 6
;	100989  JA Out(hfsUfb msg) CRLF.
;	101189  DHG Updated Stat1 tables for statistics.
;	101389  JMR changed TpInHdrs from 10 to 12.
;	101789  JMR Added default port macro
;	111489  MTR Add fileSystemPriority
;	111889  MTR FabSeg needs 2 more bytes to be right size (fix GP fault).
;	              Allow fFabUfbOwnSeg to be set in prefix file
;	113089  AT Add nSequentialDevicesMax, sgSequentialDcbSeg
;	120689  JA removed remoteDma tables.
;	120789  PGJja Changed GenDcb to DcbTemplate.
;	120889  AT Use cMegabytesOtherBoardMax correctly.
;	120889  RLMAT nRkvsUsers default is 2.
;	010990  AT Use nXBlk, sXBlk etc.
;	010990  JA cdt.sHandleTable > cdt.nDeviceHandles.
;	011090  MTR Add nDmaIob
;	011190  AT sXBlkHeader and sXBlkRqMax in pClstr and pClstrLfs.
;	             Make FS and OS config block the same up to bMasterCpCpuId.
;	011590  AT rgSbWsUserName in DGroup for noncluster SRP boards.
;	             Removed f(Sub)SysChannelABCD, only used in SinglePartition.
;	011590  SAH added rgbExtDumpMsg, cbExtDumpMsg, rgbScsiMgrVendorId, 
;	                    rgbScsiMgrProductId, rgbScsiMgrVersionId,
;	                    strings for Init_P and Fault_P
;	011890  JAY fGpBootTapeLoaderfGpBootTapeSysgen.
;	011890  JA xblock header size back to 32 for ctosp.
;	020590  JM add library search path macro, sEnvironment, sLoaderHeap.
;				 obolsete cpUSegs.
;	030290  JC added following BTOS mods:
;				 File Locking Support, Name Space in separate group
;				 Hardware Id support. KbdTimer support
;	030990  KH add sbNlsKbdFileSpec, sbNlsKbdPassword
;	032390  JA strip cluster data out; its in Data_*.asm.  Add agentParams.
;	032390  JA strip T0 support; add fClPoll, ClPollTimer.
;   032190  JM add exchQuiet. merge:
;		020790  JA add exchPit.
;	040190  JC Added allocated user number support for IDM,
;				 B28EXP support, fClstrLineSecure definition
;	042690  JC Added allocated user number variables to AgentParams
;				 Additionally, made these work only on WS, not SRP
;	61290   JMR Fix rgcommline broken structure
;	62090   RR  Merged LDM code
;	062990  JM set sExUcb for ctosv and ctosp.
;	070590  JC Removed definition for ExchHwId, using builtin now
;	070690  JA Added cPitTicksPollIntervalMax to AgentParams.
;	070690  JC Added statistics support
;	070690  JMR updated rgcommline
;	071090  DR  oPRgOExUcb
;	071890  JMR rgcommline grows
;	072190  MTR add SegMart, use for LDM structures
;	073090  GWH InterruptMask changes for External 8259 on SuperGen.
;	080890  JC  Removed fClstrLineSecure (deimplemented)
;	082090  JM  trbGinfoSet is ctosv only.
;	083090  JA  Remove FSSI stuff to SysGen_Common.mdf.
;   092090  KH  Add rgbBufIOaddr (parallel to rgbBufLeds)
;	092890  AT  Add rgbXBusTimeout.
;	101390  AT  Merge InterruptMask and HardwareInterrupt macrostables.
;	112690  JC  Added battery clock invalid message from BTOS
;	              Changed fRebootClstr field in agentparams to DWORD entry,
;	031191  JA  Move wMySlotBits,iMySlot to Data_all.
;	040491  JF  Set nDct to WsTotal insttead of 24 if not fSrp
;	040391  AT  Add rgbDefaultInt.
;	041391  KH  WS>NLSxxx
;	051391  AT  HardwareInterrupt takes bAttributes, not fEnable.
;	052991  AT  nOutstandingMax default is 5.
;	072291  JM  increase size of LargeMap and MemMap in vseries.
;	090391  JM  increase size of LargeMap and MemMap in vseries.
;	101891  AM  modifications for nNetUsers as a parameter in Config.Sys.
;				  also defined ExUcbLast based on nUcbs, not nUserNum
;	022692  sg  Add HINTR71 for OEM    
;	031892  JM  remove padding from sbNls*Spec. remove uBuf from v.
;	060592  JM  obsolete largeMap, swapMap, stoneMap. bigger memMap.
;	070192  FW  Add No ClientCard ... text string. Fix copyright notice.
;	110592  RA  Use space in rgCommLine to indicate if hardware type is pcAT.
;	110692  JF  Simplify allocated user numbers so that structures are 
;					allocated by init code.
;	111292  JF  Remove rgWakeUpRq. Remove NameCommon.  Remove all structures
;					that depend on nPartitions: rgUserReadCount, 
;					rgUserWaitCount, ContextStatus, contextState, rgcRq, 
;					rgDeltaPriority. Permit file system parameters to be
;					specified here to override file system.
;	012093  JA  Pc version.
;	021793  KK  Added hwIDCMOSAddr, hwIDCMOSChecksum, and fChecksumCMOSHwID
;	              so that the CMOS Hardware ID Address can be customized.
;	022993  SE  Allocate space for nSequentialDevicesMaxsgSequentialDcbSeg
;	030393  RA  ServerComm. Extend rgCommline, extend the rgDmaAddr
;				  structure, the 82370 DMA controller needs the
;				  RequesterAddress also to be programmed. *AA*
;	031893  JA  Remove unreferenced strings.
;	032293  RA  Sg40006000.
;	032693  JF  Add fAgentCache, fAgentCacheDefaultEnable to AgentParams
;	032993  JA  sYblk default 4160 (4k+64)
;	040193  JF  Add pfEnableCluster to AgentParams
;	040493  RA  rgDmaAddr changes again, for Sg4k6k ecomtdi. The mask,
;				  mode, clrBytePtr, cmd regs are different for rx and tx. *AA*
;	040793  sg  add IOP types to rgbtypetable. 
;	051293  JA  fHighSpeed default 1(1.8m) instead of 0(307k).
;   051493  JM  move rgTermTable out of dgroup.
;				  move Stat2, Stat3, Stat4 out of dgroup.
;   051893  sg  define psDiskStat, psProcStat, psExchStat for dgroup access.
;	060293  SE  sbVersion initialized to zeros
;	060793  JA  nZYWblkLocal
;	060993  JA  sZYWblkLocal
;	061493  JAsg  change defaults for YWblk
;	061593  RA  Change nCommline to 4 for ISDN. *AA*
;	062193  JF Add prgRqNoRemoteTermination and nRqNoRemoteTerm to AgentParams
;	062693  JM  add pnProcTick.
;	063093  SE  Report too many user numbers.
;	061593  JA  updated stat1 for local blocks, nIob>revision
;	062393  JA  FilterProcessExch out of agentParams.
;	070193  JA  Expunge periodic.  Dummy snWYZBlkLocal for nonsrp.
;   071293  JM  nWsUsers = nUserNum  nUcb
;   072793  JA  Expunge nProcTick, use pProcStat instead.  Expunge pIccStat.
;				  Expunge psProcStat, psExchStat, psDiskStat.
;	081093  JA  Expunge rgbBufOut, ibBufOutPutTake, fBufOutOverflow.
;	010594  FW  Add No ServerCard ... text strings.
;	011594  SE  fEnableCluster DB FALSE
;	013194  FW  Change text of strings added on 010594.
;	030194  JM  OsVersion := 13.2.
;	041194  FW  Further change of ServerCard text strings.

IF (not(*Isdef(fSrp))) THEN (Define(fSrp)(0))FI
IF (not(*Isdef(CTOSp))) THEN (Define(CTOSp)(0ffh))FI
IF (not(*Isdef(fMulPar))) THEN (Define(fMulPar)(0ffh))FI
IF (not(*Isdef(fVarPar))) THEN (Define(fVarPar)(0ffh))FI
IF (not(*Isdef(ctosv))) THEN (Define(ctosv)(0))FI
IF (not(*Isdef(Bsac))) THEN (Define(Bsac)(0))FI
IF (not(*Isdef(Statistics))) THEN (Define(Statistics)(0FFh))FI
IF (not(*Isdef(OSVersion))) THEN (
	IF (ctosv) THEN ( Define(OSVersion)(0D02h)
	)ELSE( Define(OSVersion)(0C03h)
	)FI
IF (not(*Isdef(fForceSlotBits))) THEN (Define(fForceSlotBits)(0))FI
)FI

Define(FS)(0)
$INCLUDE(Sysgen_Common.mdf)

; Size of intSwtbl entries
if(ctosp)then(
cwIntSwtblEntry equ 0
)else(
cwIntSwtblEntry equ 3
)fi


Define(fFP)(0)
Define(fTP)(0)
Define(fCP)(0)
Define(fSP)(0)
Define(fDP)(0)
Define(fBT)(0)
Define(fGP)(0)
IF (WsType LE awsMaster) THEN (Error(Unsupported wsType wsType))
ELSE(IF (WsType LE ngenMaster) THEN (Define(fNGenHardware)(0FFH))
ELSE(
	Define(fSrp)(0FFH)
	IF (WsType EQ FpType) THEN (Define(fFP)(0FFH))FI
	IF (WsType EQ TpType) THEN (Define(fTP)(0FFH))FI
	IF (WsType EQ CpType) THEN (Define(fCP)(0FFH))FI
	IF (WsType EQ SpType) THEN (Define(fSP)(0FFH))FI
	IF (WsType EQ DpType) THEN (Define(fDP)(0FFH))FI
	IF (WsType EQ BtType) THEN (Define(fBT)(0FFH))FI
	IF (WsType EQ GpType) THEN (Define(fGP)(0FFH))FI
)FI)FI

; initialize counters and flags
;
IF (not(*Isdef(nIOPermissionBits))) THEN (Define(nIOPermissionBits)(0))FI
IF (not(*Isdef(cParSCHeap))) THEN (Define(cParSCHeap)(16))FI
IF (not(*Isdef(fDebugger))) THEN (Define(fDebugger)(1))FI
IF (not(*Isdef(localFS))) THEN (Define(localFS)(0))FI
IF (not(*Isdef(fontRamBuf))) THEN (Define(fontRambuf)(0))FI
IF (not(*Isdef(fMulPar))) THEN (Define(fMulPar)(0))FI
IF (not(*Isdef(fVarPar))) THEN (Define(fVarPar)(0))FI
IF (not(*Isdef(fFloppyCheck))) THEN (Define(fFloppyCheck)(0))FI
IF (not(*Isdef(nRkvsUsers))) THEN (Define(nRkvsUsers)(2))FI
IF (not(*Isdef(nUserNum))) THEN (Define(nUserNum)(nUcb))FI
IF (nUserNum GE 1023) THEN (Error(Too many user numbers defined.  Maximum allowable value is 1023.))FI
IF (not(*Isdef(nNetUsers))) THEN (Define(nNetUsers)(0))FI
IF (not(*Isdef(hwIdCMOSAddr))) THEN (Define(hwIdCMOSAddr)(60h))FI
IF (not(*Isdef(hwIdCMOSChecksumAddr))) THEN (
	Define(hwIdCMOSChecksumAddr)(61h))FI
IF (not(*Isdef(fChecksumCMOSHwId))) THEN (
	Define(fChecksumCMOSHwId)(0FFh))FI
IF (not(*Isdef(nSoftVec))) THEN (Define(nSoftVec)(30+3*nUcb))FI
IF (not(*Isdef(nPartitions))) THEN (Define(nPartitions)(1))FI
IF (not(*Isdef(nPartitionsMax))) THEN (Define(nPartitionsMax)(96))FI
IF (nPartitions GT nPartitionsMax) THEN (
	SET (nPartitions, nPartitionsMax))FI
IF (not(*Isdef(nDmaIob))) THEN (
	IF (fSrp) THEN ( Define(nDmaIob)(64) )
	ELSE ( Define(nDmaIob)(0) )FI
)FI
If (Not(*Isdef(nRcb))) Then (Define(nRcb)(50))FI
IF (not(*Isdef(clusterTimeout))) THEN (
   IF(fSrp) THEN (Define(clusterTimeout)(30))
   ELSE (Define(clusterTimeout)(10))FI
)FI
IF (clusterTimeout LT 2) THEN (Define(clusterTimeout)(2))FI
Define(nRepollActive)(0)
IF (not(*Isdef(fSpecialFullyNestedMode))) THEN
   (Define(fSpecialFullyNestedMode)(0FFh))FI
IF (not(*Isdef(wsTotal))) THEN (
   IF (clusterConfig EQ 2) THEN (Define(wsTotal)(1))
   ELSE (Define(wsTotal)(0))FI
)FI
IF (not(*Isdef(nWsLine1))) THEN (Define(nWsLine1)(wsTotal))FI
IF (not(*Isdef(nWsLine2))) THEN (Define(nWsLine2)(0))FI
IF (not(*Isdef(nXBlkSmall))) THEN (Define(nXBlkSmall)(0))FI
IF (not(*Isdef(sXBlkSmall))) THEN (Define(sXBlkSmall)(0))FI
IF (not(*Isdef(nXBlk))) THEN (Define(nXBlk)(0))FI
IF (not(*Isdef(sXBlk))) THEN (Define(sXBlk)(0))FI
SET(nWsUserNum, nUserNumnPartitions)
IF (nWsUserNum EQ 0) THEN (Define(nWsUserNum)(1))Fi 
IF (not(*Isdef(fKbdRes))) THEN (Define(fKbdRes)(0FFh))FI
IF (not(*Isdef(sParExitRunFile))) THEN (Define(sParExitRunFile)(3200))FI
Define(nAsib)(nUcb)
IF (not(*Isdef(nArib))) THEN (Define(nArib)(nAsib))FI


IF (ctosv) THEN ( 
	IF (not(*Isdef(cMemMapSlots)))   THEN 
		(Define(cMemMapSlots)(nPartitions*16))FI
)ELSE(
	IF (not(*Isdef(cLargeMapSlots))) THEN (Define(cLargeMapSlots)(60))FI
	IF (not(*Isdef(cMemMapSlots)))   THEN (Define(cMemMapSlots)(60))FI
	IF (not(*Isdef(cStoneMapSlots))) THEN (Define(cStoneMapSlots)(60))FI
	IF (not(*Isdef(cSwapMapSlots)))  THEN (Define(cSwapMapSlots)(75))FI
)FI

IF (fGP) THEN (
IF (not(*IsDef(cMegabytesOtherBoardMax))) THEN
   (Define(cMegabytesOtherBoardMax)(64))FI
)FI

IF (not(*Isdef(fCheckMem))) THEN (Define(fCheckMem)(0))FI
IF (not(*Isdef(fCheckEcc))) THEN (Define(fCheckEcc)(0))FI
IF (not(*Isdef(nSwapFabs))) THEN (
	IF(ctosp) THEN (Define(nSwapFabs)(32))
	ELSE (Define(nSwapFabs)(0))FI
)FI
IF (not(*Isdef(nUsrExchange))) THEN (Define(nUsrExchange)(20))FI
IF (not(*Isdef(nPTiming))) THEN (Define(nPTiming)(20))FI
IF (ctosp) THEN (
	IF (not(*Isdef(nKbdTimers))) THEN (Define(nKbdTimers)(4))FI
)FI
IF(NOT(*ISDEF(fWrappedDebugger))) THEN (DEFINE(fWrappedDebugger)(0))FI

IF (not(*Isdef(sEnvironment))) THEN (
	IF (ctosv) THEN ( Define(sEnvironment)(1024)
	)ELSE( Define(sEnvironment)(0)
	)FI
)FI

IF (fSrp) THEN (
If (Not(*Isdef(sOutBuffer))) Then (Define(sOutBuffer)(128))FI
If (Not(*Isdef(sStatArea))) Then (Define(sStatArea)(4))FI
If (Not(*Isdef(nRcb))) Then (Define(nRcb)(40))FI
If (Not(*Isdef(nWblk))) Then (Define(nWblk)(2))FI
If (Not(*Isdef(sWblk))) Then (Define(sWblk)(65500))FI
If (Not(*Isdef(nYblk))) Then (Define(nYblk)(25))FI
If (Not(*Isdef(sYblk))) Then (Define(sYblk)(4160))FI
If (Not(*Isdef(nZblk))) Then (Define(nZblk)(150))FI
If (Not(*Isdef(sZblk))) Then (Define(sZblk)(180))FI
If (Not(*IsDef(nMountedDisks))) Then (Define(nMountedDisks)(10))Fi
If (Not(*IsDef(nFixup))) Then (Define(nFixup)(100))Fi
If (Not(*IsDef(nDeviceHandle))) Then (Define(nDeviceHandle)(200))Fi
If (Not(*IsDef(sBroadcastHeap))) Then (Define(sBroadcastHeap)(1024))Fi
If (Not(*IsDef(fGpBootTapeLoader))) Then (Define(fGpBootTapeLoader)(0))Fi

; The 80 (below) is the size of the output ring buffer for each t0 window
; If the serial ports are not going to be used, the size for windows 4 and 6
; can be made smaller, but all windows need to be a multiple of 16

If (fTP) Then (
    If (Not(*IsDef(sTpInBuf))) THEN (Define(sTpInBuf)(128))FI
    If (Not(*IsDef(sTpOutBuf))) THEN (Define(sTpOutBuf)(128))FI
) FI
)FI ' fSrp

If (Not(*Isdef(sZblk))) Then (Define(sZblk)(0))FI' For Sysgen.asm comment


if(ctosp)then(
SET (m_nSoftwareInt,  0)
)else(
SET (m_nRawInt,       0)
SET (m_nMediatedInt,  0)
)fi
SET (m_ErrorCount,    0)
SET (m_ExchLast, 1)
SET (m_SysExch, 1)
SET (m_iModDescMax, 0)
SET (m_oSbExchLast, 0)

IF(fVarpar) THEN (
EXTRN ResumeTask:FAR
)FI


;****************************************************************************
; Variables common to all Operating Systems and all FileSystems
;****************************************************************************

OEMSeg SEGMENT PARA PUBLIC 'OEMSeg'
PUBLIC rgbOemSeg
;		A pointer to this segment (the 32 byte OEM space) is returned
;		by GetpStructure (case 37).
rgbOemSeg DB 32 DUP (0)
IF(Statistics) THEN (
PUBLIC rgpStatistics
rgpStatistics	DD	DGroup:TaskSwitch
				DD	DGroup:IntTaskSwitch
				DD	DGroup:IdleProcessCycles
)FI
OEMSeg ENDS

IF (ctosv) THEN (
PUBLIC sgMax, cSgWindowableVioMax, csgPmMax
GInfoSeg SEGMENT PUBLIC 'OEMSeg'
; GInfoSeg is an OS2 structure used by PM. The Timer process maintains it.
	DB 25 DUP(0)
sgMax LABEL BYTE
	DB nUserNum		;sgMax can be updated by InitAllocUsers
	DB 44 DUP(0)
cSgWindowableVioMax LABEL BYTE
	DB nUserNum		;cSgWindowableVioMax can be updated by InitAllocUsers
csgPmMax LABEL BYTE
	DB nUserNum		;csgPmMax can be updated by InitAllocUsers
GInfoSeg ENDS
)FI

define(sUcb)(95)
UcbSeg		SEGMENT PARA PUBLIC 'OEMSeg'
rgOUcb		DW	0	;Segment gets created in lowmem by InitLowMemStructSeg
UcbSeg		ENDS

define(sExUcb)(11)
ExUcbSeg	SEGMENT PARA PUBLIC 'OEMSeg'
rgOExUcb	DW		0	;Segment gets created in lowmem by InitLowMemStructSeg
ExUcbSeg	ENDS

const SEGMENT PUBLIC 'const'
const ENDS
data SEGMENT PUBLIC 'data'
DGroup GROUP Const, Data

IF(Statistics) THEN (
PUBLIC TaskSwitch, IntTaskSwitch, IdleProcessCycles
)FI

; System configuration block
; The following variables must be in order:

EVEN

PUBLIC Config, wsType, osType, nPcb, nExchg, nMsgWait
PUBLIC hardwareType, clusterConfig, fCommIop, fMulpar
PUBLIC saSemiLowest, saSemiHighest, saTempLowest, saTempHighest, saEndMemory
PUBLIC nIob, nFcb, nFub	; Init code sets these in config block for FS to see.
PUBLIC nPTiming, nUcb
PUBLIC fLfsToMaster, vfAllowDirSlashes
Public	bMySlot, fMasterFp

PUBLIC sbOsNameClstr, sbOsNameClstrLfs, sbOsNameStnd, sbOsNameSrvr, sbVersion
PUBLIC cbOsNameMax	
; Default OsNames can be overridden by config.sys, e.g., :OsNameClstr:
cbOsNameMax			DB 20	;Max size of OsName
sbOsNameClstr		DB 6,'vClstr              ' ;must allow cbOsNameMax char
sbOsNameClstrLfs	DB 9,'vClstrLfs           ' ;must allow cbOsNameMax char
sbOsNameSrvr		DB 5,'vSrvr               ' ;must allow cbOsNameMax char
sbOsNameStnd		DB 5,'vStnd               ' ;must allow cbOsNameMax char
; The final version name is created here, and pVersionNo is set to point to it.
sbVersion		DB 50 DUP(0)

Config LABEL WORD
wsType			DB wsType
osType			DB 1	;Resident, not swapping
saSemiLowest	DW 0
if(not ctosp)then(
PUBLIC plaMemMin
plaMemMin label word
)fi
saSemiHighest	DW 0
saTempLowest	DW 0
if(not ctosp)then(
PUBLIC plaMemMax
plaMemMax label word
)fi
saTempHighest	DW 0
if(not ctosp)then(
PUBLIC plaEndMemory 
plaEndMemory label word
)fi
saEndMemory		DW 0
nPcb			DW nPcb
nExchg			DW ?
nMsgWait		DW nMsgWait
vfAllowDirSlashes	DB FALSE
fLfsToMaster	DB FALSE
nPTiming		DW nPTiming
nIob			DW 0
nFcb			DW 0
nVhb			DW 0
nUcb			DW nUcb
nFub			DW 0
hardwareType	DB hardwareType
clusterConfig	DB clusterConfig
fNoFileSystem	DB fNoFileSystem
fCommIop		DB fCommIop
fMulpar DB IF(fVarPar) THEN (3) ELSE (IF(fMulpar) THEN (0FFh) ELSE (0)FI)FI
fMasterFP		DB	0
PUBLIC bMasterFpCpuId
bMasterFpCpuId		Db	? ; Not used in FS, just for compatibility.
bMySlot				Db	?
PUBLIC bMasterCpCpuId
bMasterCpCpuId		Db	?
; OS only part (not in wrapped images)
fillCompat			DB 1 DUP(?)
public oPRgOExUcb
oPRgOExUcb dw  DGroup:pRgOExUcb
;	These two userNums are a structure. They are in sysConfig so that the installable video system service can access them.
PUBLIC userNumKbd, userNumVid
userNumVid DW 2
userNumKbd DW 2

PUBLIC orgPcb
oRgPcb    DW 0

PUBLIC oRgUserReadCount, oRgUserWaitCount
oRgUserReadCount DW ?  ;Used by InitVam, set by KernelSetup
oRgUserWaitCount DW ?  ;Used by InitVam, set by KernelSetup
fill DW 3 DUP(0)	;keeps orgsgAsib below aligned
IF(fVarpar) THEN (
	DW DGROUP:rgsgAsib ; used by debugger, debugfile
	DW 0			   ; was sAsib, now obsolete
	DD ResumeTask	 ; used by debugfile
	)FI
PUBLIC nDmaIob
nDmaIob DW nDmaIob
; End of system configuration block

IF (NOT fSrp) THEN (
; Compatibility with Srp (vars don't get set, just for linking.)
Public	pStat, pDiskStat, pCdt
PUBLIC	nMinX, nMinSmallX, nAvailX, nAvailSmallX		;DHG
PUBLIC	nInitX, nInitSmallX, nWaitX, nWaitSmallX		;DHG
Public	pProcStat, pExchStat
Public	sStat, sDiskStat,sProcStat,sExchStat,sDiskStat
cdt			DB		?
pStat		DD		Stat1
Stat1		DB		34 Dup (0)		; dummy area 
nInitX		DW		0
nMinX		DW		0
nAvailX		DW		0
nInitSmallX	DW		0
nMinSmallX	DW		0
nAvailSmallX	DW	0
nWaitSmallX	DD		0
nWaitX		DD		0
			DB		17 Dup (0)
sStat		DW		$Stat1

pDiskStat	DD		Stat2
Stat2		DB		44 Dup (0)		; dummy area
sDiskStat	DW		$Stat2

pProcStat	DD		Stat3
Stat3	Label	Word
sProcStat	DW		$Stat3

pExchStat	DD		Stat4
Stat4		Label	Word
sExchStat	DW		$Stat4


pCdt DD cdt

PUBLIC  nWblk, sWblk, nYblk, sYblk, nZblk, sZblk
PUBLIC  nWblkLocal, sWblkLocal, nYblkLocal, sYblkLocal, nZblkLocal, sZblkLocal
nWblk		DW	0
sWblk		DW	0
nYblk		DW	0
sYblk		DW	0
nZblk		DW	0
sZblk		DW	0
nWblkLocal	DW	0
sWblkLocal	DW	0
nYblkLocal	DW	0
sYblkLocal	DW	0
nZblkLocal	DW	0
sZblkLocal	DW	0
)FI' NOT SRP

PUBLIC nParDesc, nParDescMax
nParDesc	DW nPartitions
nParDescMax	DW nPartitionsMax

PUBLIC fProtected
fProtected DB IF(CTOSp) THEN (0FFh) ELSE (0)FI
if (ctosp) then(
public nGDTSlots
nGdtSlots dw nGdtSlots
public nIOPermissionBits
nIOPermissionBits dw nIOPermissionBits
public sgTssIntLast
sgTssIntLast dw 0
public sgFreeHead
sgFreeHead dw 0
public sgFreeTail
sgFreeTail dw 0
public isgGdtCallGateFirst
isgGdtCallGateFirst dw 0
public nGdtCallGates
nGdtCallGates dw 0
public pRgoGdtLink
pRgoGdtLink dd 0
PUBLIC plaEndMemory 
plaEndMemory DD 0
public pRgSgLdt
pRgSgLdt dd 0
public pRgSwapMode
pRgSwapMode dd 0
)else(
public pRgoGdtLink
pRgoGdtLink dd 0
)fi

public sSCHeap
sSCHeap dw cParSCHeap*16

IF (ctosp) THEN(
	PUBLIC sEnvironment
	sEnvironment DW sEnvironment
)FI


PUBLIC GraphicsInfo 
PUBLIC saGraphicsBoard, fGraphicsBoard, mbIOPort, bGraphicsPort
GraphicsInfo label word	;Next 7 fields are a structure, lGetpGraphicsInfo.
saGraphicsBoard DW 0
fGraphicsBoard DW 0
mbIOPort DW 8030h
bGraphicsPort DW 0
; debugger needs to know current vid hdwr parameters, cache them here
PUBLIC iLineCurrent,iColCurrent,sMapCurrent,sarCurrent,userNumVdm
iLineCurrent DB 0FFh
iColCurrent DB 0FFh
sMapCurrent DW 0
sarCurrent	DW 0
userNumVdm	DW 0

EVEN
PUBLIC wOSVersion
wOSVersion DW OSVersion


; Allocated user number block definitions
PUBLIC nUNMax, sUNBlocks, bUNBlkSHR, nUNBlocks, ExUcbLast

ExUCBLast LABEL WORD
	DW EVAL(nUcb)1	; This is the last usable ExUcb as clstr and netusers
						; do not need an ExUCB.
nUnMax LABEL WORD
	DW 3FFh				;max. no of users on a ws is set to 3FFh.
sUNBlocks LABEL WORD
	DW 8				;8 user numbers per block
bUNBlkSHR LABEL BYTE 
	DW 3				;SHR 3 = 8 user numbers per block
nUNBlocks LABEL WORD
	DW 128				;Max. no of blocks: nUnMaxsUNBlocks
EVEN

; structure of pointers for access to above locations
allocUserNumb LABEL BYTE
	DB 24 DUP (0)

org OFFSET allocUserNumb
	pbUNBlkSHR	dd	bUNBlkSHR
	prgbUNCount	dd	? 	;Set by InitAllocUsers
	pExUcbLast	dd	ExUCBLast
	pnUNBlocks	dd	nUNBlocks
	pwLocalUser	dd	?	;Set by InitAllocUsers
	prgwUNOwner	dd	?	;Set by InitAllocUsers
org OFFSET allocUserNumb+24
; End of allocated user number structures

PUBLIC pAllocUserStruct
pAllocUserStruct LABEL WORD
	DD allocUserNumb

EVEN

PUBLIC nUserNum, nWsUsers
nUserNum DW nUserNum	;Can be changed by InitAllocUsers
nWsUsers DW nUserNum  nUcb	;Can be set by :nWsUsers: in config.sys

PUBLIC fRebootClstr
fRebootClstr DB 0

; The bytes defined below are only used on CIP machines.
;
; hwIdCMOSAddr          contains the CMOS address where the hardware id is
;                       stored.
;
; hwIdCMOSChecksumAddr  contains the CMOS address where the complement of the
;                       hardware id can be stored.  This checksum byte ensures
;                       that the CMOS checksum will remain valid..
;
; fChecksumCMOSHwId     is a flag that when set true causes the complement of
;                       the hardware id byte to be written to the CMOS address
;                       specified in hwIdCMOSChecksumAddr.

PUBLIC hwIdCMOSAddr
PUBLIC hwIdCMOSChecksumAddr
PUBLIC fChecksumCMOSHwID

hwIdCMOSAddr          DB hwIdCMOSAddr
hwIdCMOSChecksumAddr  DB hwIdCMOSChecksumAddr
fChecksumCMOSHwID     DB fChecksumCMOSHwID

EVEN

nOsProcDesc DW 0	; for stack check code

; NetServerData: These variables are in a structure known by the CtNetServer.
; The NetServer calls InitNetServer (an OS common subroutine) to get a pointer
; to this structure
; ****NOTE **** This structure is known to CtNet and the Mouse and possible
; other system services. Don't insert data in the middle
PUBLIC userNumLast, userNumClstrLast, nNetUsers, NetServerData
PUBLIC  ExchNetServer
PUBLIC pRgOUcb, pRgOExUcb
PUBLIC cbNodeName,NodeName
PUBLIC pRgWsAbortRq, pRgChgUserNumRq, pRgTerminationRq, pRgSwappingRq
PUBLIC nWsAbortRq, nChgUserNumRq, nTerminationRq, nSwappingRq
NetServerData LABEL WORD
pRgWsAbortRq  DD  0
nWsAbortRq  DW  0
pRgChgUserNumRq  DD  0
nChgUserNumRq  DW  0
pRgTerminationRq  DD  0
nTerminationRq  DW  0
userNumLast  DW  nUserNum+nNetUsers1
userNumClstrLast  DW  nUserNum1
nNetUsers  DW  nNetUsers	;Can be specified in config.sys
pRgSwappingRq DD 0
nSwappingRq DW  0
exchNetServer DW 0
cbNodeName DB 0
nodeName DB 12 DUP(0)
EXTRN rgRcMax: FAR
pRgPrgNetRouting DD ?		; This table no longer exists.
pRgRcMax DD DGroup:rgRcMax
obsoleteUnused DD ?	; was bitMapExchsSave
PUBLIC userExchFirst
userExchFirst DW ?
EXTRN SysTime:WORD
pSysTime DD DGroup:sysTime
EXTRN BootBlock:WORD
pBootBlock DD DGroup:BootBlock
pRgOUcb DD rgOUcb
pRgOExUcb DD rgOExUcb
;EXTRN rgCommRawVector: WORD
; was: pRgCommRawVector DD DGroup:rgCommRawVector
PUBLIC userNumNetMin,userNumNetMax
IF(fSrp) THEN (
userNumNetMin DW 9400h	; Set by board where Net installed.
userNumNetMax DW 9400h	; Slot 37 assigned to net users.
) ELSE (
if(ctosv)then(
userNumNetMin DW nUserNum					; predefining netusers
userNumNetMax DW nUserNum+nNetUsers1
)else(
userNumNetMin DW 0	; Set by board where Net installed.
userNumNetMax DW 0
)fi
)FI
PUBLIC pAckInBuf, pAckOutBuf
obsoleteUnused2 DD 0
pAckOutBuf DD 0
pAckInBuf DD 0
EXTRN mouseData: WORD
PUBLIC pMouseData
pMouseData DD DGroup:mouseData
EXTRN rgPrgLocalServiceCode: WORD
prgPrgLocalServiceCode DD DGroup:rgPrgLocalServiceCode
PUBLIC  ExchNet
exchNet		DW	0
; End of NetServerData
;
; The following are configuration variables set from the configuration file.
; Even though they are not used by all OS configurations, they must be
; present so that InitConfig will work.

PUBLIC xBusWindowSize
xBusWindowSize DW 0 ; = 0, 96H, 224H, or 480H

; This structure is agentParamsType in CTOSTypes.  Change both places.
PUBLIC agentParams
PUBLIC paAgentStealSLForOs, nTryNewMaster, rgfSrpClock, fHighSpeed, rgNoWsLine
PUBLIC nXBlk, sXBlk, nXBlkSmall, sXBlkSmall, nOutstandingMax, nDct
PUBLIC cRcbMax, clusterTimeout, daiLocal, wsUserNumLast, nRepollActive
PUBLIC agentPriority, exchAgent, exchMstrAgentReceiver
PUBLIC fEnableCluster, pfRebootClstr
PUBLIC wPitTicksPollIntervalMax, fAgentCache, fAgentCacheDefaultEnable

agentParams LABEL BYTE

 paAgentStealSLForOs	DD ?				;0
 nTryNewMaster			DW 16				;4
 rgfSrpClock LABEL BYTE
 fHighSpeed				DB 0				;6
						DB 0				;7
 rgNoWsLine LABEL WORD
 nDct					DW nWsLine1		;8
						DW nWsLine2		;10
 nXBlk					DW nXBlk			;12
 sXBlk					DW sXBlk			;14
 nXBlkSmall				DW nXBlkSmall		;16
 sXBlkSmall				DW sXBlkSmall		;18
 nOutstandingMax		DW 5				;20
 cRcbMax				DW nRcb			;22
 clusterTimeout			DW clusterTimeout	;24
 daiLocal				DW ?				;26
 wsUserNumLast			DW nWsUserNum1	;28
 nRepollActive			DB	nRepollActive	;30
 agentPriority			DB 1				;31
 exchAgent				DW 12				;32
 exchMstrAgentReceiver	DW 17				;34
 fEnableCluster			DB FALSE			;36
 pfRebootClstr			DD fRebootClstr		;37
						DW ? 			; exchquiet space (defined elsewhere)
 pallocUserNumb			DD allocUserNumb 	;43
 wPitTicksPollIntervalMax	DW 4000			;47
 exchFilterProcess 		DW 17				;49
fAgentCache				DB 0				;51
fAgentCacheDefaultEnable	DB 0			;52
pfEnableCluster			DD fEnableCluster	;53
						DD rgRqNoRemoteTermination	;57
						DD nRqNoRemoteTermination	;61

; End of Configuration variables

PUBLIC nRkvsUsers
nRkvsUsers DW nRkvsUsers

PUBLIC FilterProcessExch
FilterProcessExch DW 4
IF (fSrp) THEN (
Even
Public	wMasterFPCdtBase, pMasterFPCdt
wMasterFPCdtBase	DW	?
pMasterFPCdt		DD	?
) FI

IF (fGP) THEN (' 1 page maps 4 megabytes.
	PUBLIC cPagesMBusWindow
	PUBLIC dMemBankMap
	cPagesMBusWindow DW (cMegabytesOtherBoardMax+3)4
	dMemBankMap DD 0
)FI


SET(nCommline, 0)
SET(nDmaAddr, 0)
IF (fTP) THEN (SET(nCommline, 4))FI
IF (fCP) THEN (SET(nCommline, 2))FI
IF (fGP) THEN (SET(nCommline, 8) SET(nDmaAddr, 8))FI
IF (fNGenHardware AND ctosp) THEN (SET(nCommline, 4) SET(nDmaAddr, 8))FI
IF (fNGenHardware AND NOT ctosp) THEN (SET(nCommline, 2))FI

IF (nCommline GT 0) THEN (
;Set during init time for the size of rgCommLine
PUBLIC nrgCommLine
nrgCommLine		DW	0
PUBLIC rgCommLine
rgCommLine LABEL DWORD
SET(irgCommLine, 0)
WHILE(irgCommLine LT nCommline) (
				DD 9 DUP(0) ;4 raw procs + 4 procs + pDsBx
				DW 4 DUP(0)	;4 IO addr
				DW 0FFFFh	;Unused usernumber
				DW irgCommLine	;commlinehandle
				DW 0		;ldtr
				DB 0	;fDma
				DB 0	;fDma Availible
				DB 0	;NRZI type
				DB 0	;ChipType
				DW 0	;BaudrateIO reg
				DW 0	;BRGModeReg for 8253 type clocking
				DB 0	;Baud rate type for handling HW specific initalization
				DB 0	;ExtCtlRegImage
				DD 0	;pExtCntRegImg so that channels AB can share an image
				DW 0	;ExtCtlReg
				DW 0	;ExtStatReg
				DW 0	;ExtClkCntReg
				DB 0 	;TRxDirMask
				DB 0 	;DTRSourceMask
				DW 0	;ioExtra1 for 2681
				DW 0	;ioExtra1 for 2681
				DW 0	;ioExtra1 for 2681
				DW 0	;IntOpMask for interrupt controler (en)(dis)able
				DB 0	;ExtStatRegType
				DB 0	;ExtCntRegType
				DB 0	;fPCAT *AA*
				DB 0	;RTxDirMask
				DW 0	; .

SET(irgCommLine, irgCommLine + 1)
)

)FI' nCommLine

; one DmaAddr structure is needed for each communications port that supports
; comm dma.  For each pair of channels, one CommDmaEnable word is required.
;

PUBLIC rgDmaAddr
rgDmaAddr LABEL WORD
SET(irgDMAAddr, 0)
WHILE(irgDMAAddr LT nDmaAddr) (
				'DW 13 DUP(0)
				dw  2 dup(0)	;dma AddrReg (RxTx)
				dw  2 dup(0)	;dma CountReg (RxTx)
				dw  2 dup(0)	;ear (1623 address) (RxTx)
				dw  2 dup(0)	;ear (2332 address) (RxTx)
				dw  2 dup(0)	;dma MaskReg (RxTx)
				dw  2 dup(0)	;dma ModeReg (RxTx)
				dw  2 dup(0)	;dma BytePtrClr (RxTx)
				dw  1 dup(0)	;ear EnableReg
				dw  2 dup(0)	;dma CmdReg (RxTx)
				DB  6 DUP(0)
				DW  2 DUP(0)
				DD  2 DUP(0)	;DMA mapper for XE
				DW	2 DUP(0)	;ModeReg2, CmdReg2 *AA*
				DW  2 DUP(0)	;ReqAddrRegLow *AA*
				DW  2 DUP(0)	;ReqAddrRegHigh *AA*
SET(irgDMAAddr, irgDMAAddr + 1)
)

PUBLIC rgCommDmaEnable
rgCommDmaEnable	DB	(0)

; The EventControlBlock is a structure that is used mostly for mail. A
; pointer is returned by GetPStructure.
PUBLIC EventControlBlock
eventControlBlock DW 32 ; The first word contains the length in bytes.
	DB  32 DUP(0)

PUBLIC nTicks
nTicks  DB 4
PUBLIC cFramesMax
cFramesMax DB nFrames

PUBLIC extCntlRegAws
extCntlRegAws DB 0

IF ((sKbdBuffer LT 16) OR (sKbdBuffer GT 1024)) THEN(Error(sKbdBuffer out of range) SET(sKbdBuffer,128))FI
IF (((sKbdBuffer1) AND sKbdBuffer) NE 0) THEN(Error(sKbdBuffer not a power of 2) SET(sKbdBuffer,128))FI
EVEN
PUBLIC contingencyLog
contingencyLog DW sContingencyLog DUP (0)
PUBLIC sBufOut, mBufOut
mBufOut DW sKbdBuffer1
sBufOut DW sKbdBuffer

IF (not(*Isdef(sIBusBuffer))) THEN (Define(sIBusBuffer)(64))FI
IF (((sIBusBuffer1) AND sIBusBuffer) NE 0) THEN(Error(sIBusBuffer not a power of 2) SET(sIBusBuffer,128))FI
rgbBufLEDs DB sIBusBuffer DUP(0)
rgbBufIOaddr DB sIBusBuffer DUP(0)
ibBufLEDsPut DW 0
ibBufLEDsTake DW 0
maskiBufLED DW sIBusBuffer1
PUBLIC rgbBufLEDs, ibBufLEDsPut, ibBufLEDsTake, maskiBufLED, rgbBufIOaddr

if(ctosp)then(
PUBLIC nSoftwareInt
nSoftwareInt  DW 0
PUBLIC nHardwareInt
nHardwareInt  DW 0
)else(
PUBLIC nRawInt, nMediatedInt
nRawInt  DW 0
nMediatedInt DW 0
)fi
PUBLIC sExec
sExec  DW sParExitRunFile

PUBLIC pXlatTable, wXlatTableChksum, pUserXlatTable
pXlatTable			DD 0
wXlatTableChksum	DW 0
pUserXlatTable		DD 0

PUBLIC nSwapFabs
nSwapFabs			DW nSwapFabs

IF (ctosp) THEN (
PUBLIC nKbdTimers, rgiKbdTimer
nKbdTimers		DW nKbdTimers
rgiKbdTimer		DW nKbdTimers DUP (0)
)FI

IF(fVarPar)THEN(
PUBLIC exchSched,exchSchedPocket, exchQuiet
exchSched	DW	6
exchSchedPocket	DW	? ;leave space for AllocSysExch to fill
exchQuiet DW ?
)ELSE(IF(fMulPar)THEN(
PUBLIC exchQuiet
exchQuiet DW 5 ;exchTermination
)FI)FI
PUBLIC exchRqTracker, exchSpecHeap, exchOSNamePlace, exchPit
exchRqTracker DW ? ;AllocSysExch initializes
exchSpecHeap  DW ?
exchOSNamePlace  DW ?
exchPit DW ?

PUBLIC fWrappedDebugger
fWrappedDebugger DB fWrappedDebugger

PUBLIC tyDevMax, mptyDevMask, sgRgHwIntDescInit, sgRgHardwareIntDesc
tyDevMax DW tyDevLast+1
mptyDevMask DW tyDevLast+1 DUP(0,0,0,0,0,0)	; Filled out in InitIoAddr.plm.
sgRgHwIntDescInit DW HwIntDescInitSeg
sgRgHardwareIntDesc DW 0

EVEN

; irgoExchReal identifies the virtual exchange table used to map exchanges
PUBLIC irgoExchReal
irgoExchReal LABEL BYTE
IF(fSrp)THEN(
	IF((fFP)OR(fDP))THEN(DB 4)FI
	IF(fTP)THEN(DB 5)FI
	IF(fCP)THEN(DB 6)FI
	IF(fSP)THEN(DB 7)FI
	IF(fGP)THEN(DB 8)FI
	IF(fNGenHardware)THEN(DB 11)FI
)ELSE(
	IF(clusterConfig EQ 0)THEN(DB 2)FI 'standalone
	IF(clusterConfig EQ 1)THEN('cluster
		IF(localFS EQ 0)THEN(DB 0)ELSE(DB 1)FI
		)FI
	IF(clusterConfig EQ 2)THEN(DB 3)FI 'master
)FI

IF(Statistics) THEN (
TaskSwitch	DD 0
IntTaskSwitch	DD 0
IdleProcessCycles	DD 0
)FI

;****************************************************************************
; Bsac extensions
;****************************************************************************
if (bsac) then (
PUBLIC fBsacResident, fAcsResident, UserNumAcs, RgTrustLevel

fBsacResident	DB	0
fAcsResident	DB	0
UsernumAcs		DB	0
RgTrustLevel	DW	nPartitions DUP (0)
)fi


;****************************************************************************
; Parameters for the multipartition OS
;****************************************************************************
;
IF (fMulPar) THEN (
PUBLIC oExUcb
PUBLIC saMaxPartition
PUBLIC cbExtDumpMsg, rgbExtDumpMsg
IF (fVarPar) THEN (
PUBLIC rgsgAsib
PUBLIC nAsib, nArib
PUBLIC sbSwapFileTryFirst
PUBLIC sbSwapFileTryFirstPswd
PUBLIC sbSwapFileTryEach
PUBLIC sbSwapFileTryEachPswd
PUBLIC ibSwapFileNumber
PUBLIC swapFileSize
PUBLIC pMemMap
PUBLIC cMemMapSlots
)FI

EVEN
oExUcb  DW 0
saMaxPartition DW 0
PUBLIC	timeSliceLb, timeSliceHb, fTimeSlice
timeSliceLb DB lbTimeSlicePriority
timeSliceHb DB hbTimeSlicePriority
fTimeSlice DB fTimeSliceEnable


IF (fVarPar) THEN (
AsibOs SEGMENT PUBLIC 'OEMSeg'
	DB 256 DUP(0)
AsibOs ENDS
; This array is not based, and its size won't change.
; We always leave enough room for the max size.
rgsgAsib LABEL WORD
	DW AsibOs
	DW nPartitionsMax1 DUP(0)
nAsib  DW nAsib
nArib  DW nArib
pMemMap         DD 0
cMemMapSlots    DW cMemMapSlots
)FI

IF (not(*Isdef(nUSeg))) THEN (Define(nUSeg)(32))FI
PUBLIC rgUSegCb, rgUSegfLL, cUSeg, cUSegMax
cUSegMax  DW nUSeg

cUSeg 	  DW 0
rgUSegCb  DW nUSeg DUP(0)
rgUSegfLL DB nUSeg DUP(0)

) FI' Mulpar

;****************************************************************
;  If the CTOS becomes too big to load the font, one can 
;  reserve 8704 bytes at low memory which will be used by 
;  LoadFontRam operations. To reserve this font buffer, one 
;  should set FontRamBuf to 0FFh before Init Macro in Sysgen.asm     
;****************************************************************

IF (FontRamBuf NE 0) THEN (
EVEN
Sysgen_LowMem SEGMENT PUBLIC 'LowMem'
fontRamBuf DB 8704 DUP (0)
Sysgen_LowMem ENDS
) FI

;****************************************************************
;  The following are the text portions of the messages put out  
;  by the CTOS Operating System     
;****************************************************************

; The following is the header of the crash message put out by the OS.
;  The entire message looks like :
; CRASH STATUS (ERC 22.) 16H  5H  0H  0H  0H  0H  31C0H  22H

PUBLIC rgCrashMsg, cbRgCrashMsg
cbRgCrashMsg DB 17  ; The size of the message string
rgCrashMsg DB 'CRASH STATUS ',28h,'ERC'

; The following is the previous crash message put out by the OS when it is
; rebooted. The entire message looks like :
; LAST CRASH STATUS (ERC 22.) 16H  5H  0H  0H  0H  0H  31C0H  22H

PUBLIC rgLastCrashMsg, cbRgLastCrashMsg
cbRgLastCrashMsg DB 22 ; length of the text string
rgLastCrashMsg  DB 'LAST CRASH STATUS ',28h,'ERC'

; The following is the message put out by the cluster workstation OS when it
; detects that the master workstation is down.  The entire message looks like:
; CLUSTER NOT RUNNING, ERC = 6

PUBLIC rgClusterMsg, cbRgClusterMsg
cbRgClusterMsg DB 26  ; length of the text string
rgClusterMsg DB 'CLUSTER NOT RUNNING, ERC ='

; The following is the message put out by the OS when the exit run file cannot
; be loaded.  The entire message looks like:
; CANNOT LOAD EXIT RUN FILE, ERC = 203

PUBLIC rgExitFileError, cbRgExitFileError
cbRgExitFileError DB 32 ; length of the text string
rgExitFileError  DB 'CANNOT LOAD EXIT RUN FILE, ERC ='

; The following is the message put out by the OS when some hardware error is
; detected during its initialization.  The entire message looks like:
; INITIALIZATION ERROR STATUS 8000H

PUBLIC rgInitError, cbRgInitError
cbRgInitError DB 27  ; length of the text string
rgInitError DB 'INITIALIZATION ERROR STATUS'

; The following is the name given to the primary partition.

PUBLIC	cbPriParName, rgPriParName
cbPriParName DB 7  ; length of the text string
rgPriParName DB 'Primary'

; The following is the default name given to a partition in which a system
; service resides.

PUBLIC cbSysSvcParName, rgSysSvcParname
cbSysSvcParName DB 12  ; length of the text string
rgSysSvcParName DB 'SysService00'

; The following is printed when the user needs to run Extended Crash Dump and
; then reboot, in order to regain memory above 1 or 4 Mb.
cbExtDumpMsg  DB 58 ; length of the text string
rgbExtDumpMsg DB 'Run Extended Crash Dump and reboot to regain high memory.',10

; The following is printed when a ClientCard cannot be found by a cluster CTOS
; running on a CIPCPE machine. 
PUBLIC cbNoClientCard, rgbNoClientCard
cbNoClientCard  DB 52 ; length of the text string
rgbNoClientCard DB 'A Unisys CTOS ClientCard is required, but not found.',10
; The following is printed when a old revision ClusterCard is found by CTOS
; running on a CIPCPE machine. 
PUBLIC cbWrongClientCard, rgbWrongClientCard
cbWrongClientCard  DB 55 ; length of the text string
rgbWrongClientCard DB 'Unisys ClientCard required, ClusterCard is not usable.',10
; The following is printed when the ClientCard switches are set wrong when
; running on a CIPCPE machine. 
PUBLIC cbWrongClientCardSW, rgbWrongClientCardSW
cbWrongClientCardSW  DB 53 ; length of the text string
rgbWrongClientCardSW DB 'Incorrect switch settings on Unisys CTOS ClientCard.',10
; The following is printed when a ServerCard cannot be found
; by CTOS running on a CIPCPE machine. 
PUBLIC cbNoServerCard, rgbNoServerCard
cbNoServerCard  DB 53 ; length of the text string
rgbNoServerCard DB 'A Unisys CTOS ServerCard is required, but not found.',10
; The following is printed when an old ClientCard is found by CTOS
; running as a server on a CIPCPE machine. 
PUBLIC cbWrongServerCard, rgbWrongServerCard
cbWrongServerCard  DB 61 ; length of the text string
rgbWrongServerCard DB 'The installed ClientCard is not capable of server operation.',10
; The following is printed when the ServerCard switches are set wrong when
; running on a CIPCPE machine as a server. 
PUBLIC cbWrongServerCardSW, rgbWrongServerCardSW
cbWrongServerCardSW  DB 53 ; length of the text string
rgbWrongServerCardSW DB 'Incorrect switch settings on Unisys CTOS ServerCard.',10
; The following is printed when attempting to boot CTOS on a 286 or lower
; running on a CIPCPE machine. 
PUBLIC cbNeed386, rgbNeed386
cbNeed386  DB 52 ; length of the text string
rgbNeed386 DB 'This CTOS operates only with 80386 and higher CPUs.',10

; The following are sent to WriteLine in Init_P.asm and Fault_P.plm
PUBLIC rgbGpFault, rgbDoubleFault, rgbDivideFault, rgbOverflowFault
PUBLIC rgbRangeFault, rgbBogusOpFault, rgbBogusTssFault, rgbNotPresentFault
PUBLIC rgbStackFault, rgbXBusTimeout, rgbDefaultInt
PUBLIC rgbNmiFault, rgbPageFault, cbNmiAddr, rgbNmiAddr, cbBusTimeout
PUBLIC rgbBusTimeout, cbMemParity, rgbMemParity, cbDuringDMA, rgbDuringDMA
PUBLIC cbUtilReg, rgbUtilReg

rgbGpFault         db 'GP fault',0
rgbDoubleFault     db 'Double fault',0
rgbDivideFault     db 'Divide fault',0
rgbOverflowFault   db 'INTO',0
rgbRangeFault      db 'Range fault',0
rgbBogusOpFault    db 'Bogus op',0
rgbBogusTssFault   db 'Invalid TSS',0
rgbNotPresentFault db 'Not present fault',0
rgbStackFault      db 'Stack fault',0
rgbDefaultInt      db 'Default int vector',0
rgbXBusTimeout     db 'XBus timeout',0
rgbNmiFault        db 'Non Maskable Interrupt',0
rgbPageFault       db 'Page fault',0

cbNmiAddr          dw 13
rgbNmiAddr         db 'nmi address: '

cbBusTimeout       dw 13
rgbBusTimeout      db 'Bus timeout: '

cbMemParity        dw 15
rgbMemParity       db 'Memory parity: '

cbDuringDMA        dw 12
rgbDuringDMA       db '(during dma)'

cbUtilReg          dw 18
rgbUtilReg         db 'Utility register: '

EVEN

;****************************************************************************
; Variables common to all ctosv
;****************************************************************************
IF ((ctosp) AND (NOT(ctosv))) THEN (
; UBuf used by termination  must be paragraph aligned
; segment is classed with const so its not coeded
PUBLIC uBuf
uBufSeg SEGMENT PARA PUBLIC 'Const'
UBuf DW 256 DUP(?)
uBufSeg ENDS
DGroup GROUP uBufSeg

)FI

;****************************************************************************
; Variables common to all CTOS
;****************************************************************************

; The following is the name of the run file which is chained to by all NGen OSs
; before SysInit in order to check the XBus configuration

PUBLIC rgCheckConfig, cbRgCheckConfig
cbRgCheckConfig DB 27  ; The size of the message string
rgCheckConfig DB '[Sys]<Sys>DisplayConfig.run'

PUBLIC rgCheckConfigPswd, cbRgCheckConfigPswd
cbRgCheckConfigPswd DB 0 ; The size of the message string
rgCheckConfigPswd DB 0

PUBLIC cbCrashDumpPath, rgbCrashDumpPath, cbCrashDumpPassword, rgbCrashDumpPassword

IF(fSrp) THEN (
cbCrashDumpPath		DW	10
rgbCrashDumpPath	DB	'[sys]<sys>', 18 DUP(0)
cbCrashDumpPassword		DW	0
rgbCrashDumpPassword	DB	12 DUP(0)

) ELSE (' WS
rgbCrashDumpPath	DB	'[sys]<sys>'
cbCrashDumpPath		DW	10
rgbCrashDumpPassword	LABEL BYTE	;password not allowed
cbCrashDumpPassword		DW	0
)FI

EVEN
;****************************************************************************
; Variables for Ngen Master  vMstr
;****************************************************************************
IF ((wsType EQ ngenMaster) AND NOT fSrp) THEN (
PUBLIC fGraphicsBoard
) FI' wsType = ngenMaster
EVEN


;****************************************************************************
; Variables for all SRP
;****************************************************************************
IF (fSrp) THEN (


PUBLIC fForceSlotBits
fForceSlotBits DB fForceSlotBits

If (fGP) Then (
	Public fGpBootTapeSysgen
	fGpBootTapeSysgen DB fGpBootTapeLoader
) Fi


pCdt		DD	Cdt

const	segment word public 'CONST'
PUBLIC	rgbTypeTable, rgbXpChar, srgbTypeTable
IF(fNGenHardware) THEN (
rgbTypeTable	DB  0,4,32,33,34,35,63
rgbXpChar		DB	'?EEEEEE'
srgbTypeTable	DW	7
) ELSE (
rgbTypeTable	DB  0,10,11,12,13,14,15,16,20,21,22,64,65,0FFh
rgbXpChar		DB	'?FTCSDRNGGGAAB'
srgbTypeTable	DW	14
)FI'
const	ENDS

oRgClusterTerm  DW	0
fSrpUp			DB	0

PUBLIC exchFilterPocket
exchFilterPocket DW ?

Public  Mask186
If (fFP) Then (
Mask186		DW	0FFh21h
) Else (
If (fTP) Then (
Mask186		DW	0FFh20h
) Else (
If (fCP) Then (
Mask186		DW	0FFh30h
) Else (
If (fDP) Then (
Mask186		DW	0FFh21h
) Else (
Mask186		DW	0FFh21h
) Fi) Fi) Fi) Fi

Even

If (fCP OR fGP) Then (

EVEN

; PTs are no longer supported (CTOSSRP 3.0)
;
; TP polling is supported on CP.

Public nsTpInBuf, nsTpOutBuf
nsTpInBuf	dw	sTpInBuf
nsTpOutBuf	dw	sTpOutBuf
TpInHdrs	equ	12
TpOutHdrs	equ	30
Public sTpInHdr, sTpOutHdr
sTpInHdr	dw	TpInHdrs
sTpOutHdr	dw	TpOutHdrs 
PUBLIC fClPoll,ClPollTimer
fClPoll			DB 0FFh
ClPollTimer		DB 0FFh

Public rgTpInBuffers, rgTpOutBuffers
rgTpInBuffers	db	3*sTpInBuf + 3*TpInHdrs dup(0)
rgTpOutBuffers	db	3*sTpOutBuf + 3*TpOutHdrs + 3 dup(0)
alignment	Dw	6 Dup (0)
overwritten	Db	'CTOS'

) Else (' Not CP or GP
    If (fTP) Then (
	EVEN

	Public nsTpInBuf, nsTpOutBuf
	nsTpInBuf	dw	sTpInBuf
	nsTpOutBuf	dw	sTpOutBuf

	Public sTpInHdr, sTpOutHdr
	TpInHdrs	equ	12
	TpOutHdrs	equ	30
	sTpInHdr	dw	TpInHdrs
	sTpOutHdr	dw	TpOutHdrs 

	Public rgTpInBuffers, rgTpOutBuffers
	rgTpInBuffers	db	10*sTpInBuf + 10*TpInHdrs dup(0)
	rgTpOutBuffers	db	10*sTpOutBuf + 10*TpOutHdrs + 10 dup(0)

	alignment	dw	20 dup (0)	; since qual alignment now
	overwritten	db	'CTOS'
    ) Fi
) FI
		EVEN

PUBLIC  nRcb, nWblk, sWblk, nYblk, sYblk, nZblk, sZblk
PUBLIC  nWblkLocal, sWblkLocal, nYblkLocal, sYblkLocal, nZblkLocal, sZblkLocal
nRcb		DW	nRcb
nWblk		DW	nWblk
sWblk		DW	sWblk
nYblk		DW	nYBlk
sYblk		DW	sYblk
nZblk		DW	nZblk
sZblk		DW	sZblk
nWblkLocal	DW	nWblk
sWblkLocal	DW	sWblk
nYblkLocal	DW	nYblk
sYblkLocal	DW	sYblk
nZblkLocal	DW	nZblk
sZblkLocal	DW	sZblk

PUBLIC	sBroadcastHeap
sBroadcastHeap DW sBroadcastHeap

EVEN

SET(iFixUp, 0)
WHILE(iFixUp LT nFixUp) (
LabiFixup LABEL BYTE
IF (iFixUp EQ 0) THEN (
	DW 0
)ELSE(
SET(iLabel,iFixup1)
	DW OFFSET DGroup:LabiLabel
)FI
	DW 0,0,0
SET(iFixup, iFixUp+1)
)

SET(iLabel,nFixup1)
Public	oFixupFree, oFixupHead
oFixupFree	DW	OFFSET DGroup:LabiLabel
oFixupHead	DW	0


if (NOT fNoFileSystem) Then (

IF (NOT(*ISDEF(nSequentialDevicesMax))) THEN (
	DEFINE(nSequentialDevicesMax)(8)
)FI
PUBLIC nSequentialDevicesMax, sgSequentialDcbSeg
nSequentialDevicesMax	DW nSequentialDevicesMax
sgSequentialDcbSeg		DW 0

sMountTabEntry		Equ	1+13+13

; Allocate a mount table entry for each possible
;    MassStorage device          SysGen parameter.
;    SequentialStorage device    SysGen parameter.
;    Booted board     (36)       6 cabinets, 6 processors each.
;    ScsiManagerName   (8)       Maximum number of FileSystems.
;    RemoteCacheName  (12)       A reasonable limit for a normal system.
;    MasterFP, etc.  (4)       Any odds and ends.

Public maxDevMounted, nDevMounted
maxDevMounted		Dw	nMountedDisks+nSequentialDevicesMax+60
nDevMounted			Dw	0

) ELSE (' NonFileSystem board dummy
PUBLIC nSequentialDevicesMax, sgSequentialDcbSeg
nSequentialDevicesMax	LABEL WORD
sgSequentialDcbSeg		LABEL WORD
) Fi

nDummy		Equ		5			; padding of each area
			Even
Public	pStat, pDiskStat, pCdt
Public	pProcStat, pExchStat
Public	sStat, sDiskStat, sProcStat, sExchStat
PUBLIC	nMinX, nMinSmallX, nAvailX, nAvailSmallX		;DHG
PUBLIC	nInitX, nInitSmallX, nWaitX, nWaitSmallX		;DHG
PUBLIC	nMinW, nMinY, nMinZ, nAvailW, nAvailY, nAvailZ
;DHG...
PUBLIC	nWaitY, nWaitZ, nWaitW
;...DHG
;JA...
PUBLIC	nWaitWLocal, nWaitYLocal, nWaitZLocal
PUBLIC	nMinWLocal, nInitWLocal, nAvailWLocal
PUBLIC	nMinYLocal, nInitYLocal, nAvailYLocal
PUBLIC	nMinZLocal, nInitZLocal, nAvailZLocal
;...JA
PUBLIC	nLocRead, nLocWrite, nLocSeeks
Public	nRemRead, nRemWrite, nRemSeeks, nExchIn
Public	nInitW, nInitY, nInitZ
Public	nIobUsed
PUBLIC  nMinFAB, cFreeFab
pStat		DD		Stat1
Stat1		Label	Word
			DW		6
Stat1nPcb LABEL WORD
			DW		nPcb
Stat1nUsrExchangeplus30 LABEL WORD
			DW		nUsrExchange+30 ; 30 is guess at upper limit m_nSysExch.
nInitY		DW		nYblk
nMinY		DW		nYblk
nAvailY		DW		nYblk
nInitZ		DW		nZblk
nMinZ		DW		nZblk
nAvailZ		DW		nZblk
revision	DW		1
reserved	DW		0
reserved2	DW		0
nMinFAB		DW		0
cFreeFab	DW		0 ;incremented to nFab by InitFile.
nInitW		DW		nWblk
nMinW		DW		nWblk
nAvailW		DW		nWblk
;DHG...
nInitX		DW		nXblk
nMinX		DW		nXblk
nAvailX		DW		nXblk
nInitSmallX	DW		nXBlkSmall
nMinSmallX	DW		nXBlkSmall
nAvailSmallX	DW	nXBlkSmall
nWaitSmallX	DD		0
nWaitX		DD		0
nWaitW		DD		0
nWaitY		DD		0
nWaitZ		DD		0
;...DHG
; JA...
nWaitWLocal	DD		0
nWaitYLocal	DD		0
nWaitZLocal	DD		0
nInitYLocal	DW		nYblk
nMinYLocal	DW		nYblk
nAvailYLocal	DW	nYblk
nInitZLocal	DW		nZblk
nMinZLocal	DW		nZblk
nAvailZLocal	DW	nZblk
nInitWLocal	DW		nWblk
nMinWLocal	DW		nWblk
nAvailWLocal	DW	nWblk
;...JA
			DW		nDummy Dup (0)
sStat		DW		$Stat1

pDiskStat	DD		Stat2
StatsSeg	SEGMENT WORD PUBLIC 'OemSeg'
Stat2		Label	Word
nLocRead	DW		6 Dup (0)		; 6 is max possible  disksprocessor
nLocWrite	DW		6 Dup (0)
nLocSeeks	DW		6 Dup (0)
nRemRead	DW		6 Dup (0)		; 6 is max possible  disksprocessor
nRemWrite	DW		6 Dup (0)
nRemSeeks	DW		6 Dup (0)
nIobUsed	DW		6 Dup (0)
			DW		nDummy Dup (0)
sStatSeg EQU	$Stat2
StatsSeg    ENDS
sDiskStat	DW		sStatSeg

pProcStat	DD		Stat3
StatsSeg	SEGMENT WORD PUBLIC 'OemSeg'
Stat3		Label	Word
			DW		nPcb DUP (0)
			DW		nDummy Dup (0)
sStatSeg	EQU		$Stat3
StatsSeg    ENDS
sProcStat	DW		sStatSeg

pExchStat	DD		Stat4
StatsSeg	SEGMENT WORD PUBLIC 'OemSeg'
Stat4		Label	Word
						 ; 30 is guess at upper limit m_nSysExch.
nExchIn		DW		(nUsrExchange+30) DUP (0)
			DW		nDummy Dup (0)
sStatSeg	EQU		$Stat4
StatsSeg    ENDS
sExchStat	DW		sStatSeg

CdtSeg	Segment	Public	'Cdt'

; define a Cdt, but with the offsets, etc. in 8086 format.

StatOffset		Equ	Offset StatArea  Offset Cdt
If (NOT fNoFileSystem)Then (
HandleOffset	Equ	Offset HandleArea  Offset Cdt
)Fi

Cdt			Label	Byte

'paIccSeg'			DB	4 Dup (?)
'filler$0 (4)'		DB	4 Dup (?)
'bProcessorType'	DB	hardwareType
'fWatchDog'		DB	0
'fWashDisable'		DB	0
'filler$1 (0Bh)'	DB  11 Dup (?)
'qMemorySize'		DD  ?
'fLockByte'		DB	0
'bInitErrorStatus'	DB	0
'bMemorySize'		DB	?
'bBootStruct$FF'	DB	0FFh
'bBootStruct$0'	DB	0
'bBootStruct$A6'	DB	0A6h
'bBootCommand'		DB	0
'bMasterFP'		DB	?
'fOsInitialized'	DB	0
'fCdtIO'			DB	0
'oStatArea'		DW	StatOffset
'sStatArea'		DW	sStatArea
'rgbFPXlate'		DB	8 Dup (?)
'rgbBusConfigTable'DB	240 Dup (?)
'nUserNumber'		DW	?
'bTTiStatus'		DB	?
'bTTiData'			DB	?
'bTToStatus'		DB	?
'bTToData'			DB	?
'wPanelStatus'		DW	?
'bFrontPanel'		DB	?
'fDegraded'		DB	?
'bDumpCommand'		DB	?
'fDisCls'			DB	?
'wCpWho'			DW	?
'WCpTimer'			DW	?
'verifyCode'		DB	?
'bBoardsNotReady'	DB	?
'paConfigFile'		DD	?
'cbConfigFile'		DW	?
'cLocalUserNums'	DW  nPartitions
'userNumMax'		DW  nUserNum1
'filler$2 (3Ch)'	DB	60 Dup (?)


    ; Following portion of the table is file processor specific

If (NOT fNoFileSystem) Then (

'oHandleTable'		DW	HandleOffset
'sHandleTable'		DW	nDeviceHandle
'oHandleFree'		DW	?

'nDevMounted'		DW	0
'paMasterMountTable' DD	0
'rgObit(5)'		DB	5 Dup (0)
'filler$3 (3)'		DB  3 Dup (?)
) Fi
		Even
StatArea	DW	sStatArea Dup (?)
		Even
If (NOT fNoFileSystem) Then (
HandleArea	DB	nDeviceHandle*6 Dup (?)
) Fi
	Even
CdtSeg	Ends

) ELSE (
PUBLIC nSequentialDevicesMax, sgSequentialDcbSeg
nSequentialDevicesMax	DW 0
sgSequentialDcbSeg		DW 0
)FI' ALL SRP


IF (clusterConfig EQ standAlone) THEN (
; dummy labels for StandAlone
PUBLIC sgMyShadow, pSgMyIcc
sgMyShadow LABEL BYTE
pSgMyIcc DD 0
)FI


EVEN

;****************************************************************************
; MACRO DEFINITIONS
;****************************************************************************
;
;

$EJECT
;
; macro for encryption key and buffer
;
*DEFINE (DefineEncryptionKey (wKeyValue))(
; Allocate room for sbType for GetpStructure, but set public to actual data.
; First reserve room for the cb, define the key, org back and fill in the cb.
PUBLIC EncryptionKey
_sbCb_			db ?
EncryptionKey	dw wKeyValue
EncryptionKeyEnd label byte
_cbKey_ EQU OFFSET EncryptionKeyEnd  OFFSET EncryptionKey
ORG OFFSET _sbCb_
				DB _cbKey_
ORG OFFSET EncryptionKeyEnd
)

$EJECT
IF (0) THEN (' Obsolete real mode macros
;
; macro for defining real mode raw interrupt handler structure
;
*DEFINE (RawInterrupt (level,entry))(
IF (m_nRawInt EQ 0) THEN (
PUBLIC rgRawIntDesc 
rgRawIntDesc	LABEL	WORD
) FI
EXTRN(entry)
DB level
DD entry
SET(m_nRawInt, m_nRawInt+1)
)
;
; Macro for defining real mode mediated interrupt handler structure.
;
*DEFINE (MediatedInterrupt (type,f8259,entry))(
IF (m_nMediatedInt EQ 0) THEN (
PUBLIC rgMediatedIntDesc
rgMediatedIntDesc	LABEL	WORD
) FI
EXTRN(entry)
DB type,f8259
DD entry
SET(m_nMediatedInt, m_nMediatedInt+1)
)
)FI' Obsolete real mode macros

$EJECT
;
; macro for defining protected mode software interupt handler structure
;
*DEFINE (SoftwareInterrupt (level,entry,sStack,fMediated))(
IF (m_nSoftwareInt EQ 0) THEN (
PUBLIC rgSoftwareIntDesc
rgSoftwareIntDesc	LABEL	WORD
) FI
EXTRN(entry)
DB level
DD entry
DW sStack
DB fMediated
SET(m_nSoftwareInt, m_nSoftwareInt+1)
)

$EJECT
;
; Macros for defining protected mode hardware interrupt handler structure.
;
DEFINE(m_oHwInt)(0)
DEFINE(m_cHwInt)(0FFFFh)
sHwIntDescInit EQU 17

*DEFINE(HardwareInterrupt(iInt,tyDev,chip,bit,wMem,entry,sStack,attr))(
IF (tyDev EQ tyController) THEN (
	; Create rgHwIntTableDesc (oRgHwIntDescInit, cHwIntDescInit) in DGroup.
	IF (NOT IsDef(rgHwIntTableDesc)) THEN (
		PUBLIC rgHwIntTableDesc
		rgHwIntTableDesc LABEL WORD
	) FI
	IF (NOT(m_cHwInt EQ 0FFFFh)) THEN (
		DW m_cHwInt
	) FI
	DW m_oHwInt
	DEFINE(m_cHwInt)(0)
) FI
HwIntDescInitSeg SEGMENT WORD PUBLIC 'MEMORY'
IF (NOT IsDef(rgHwIntDescInit)) THEN (
	PUBLIC rgHwIntDescInit
	rgHwIntDescInit LABEL WORD
) FI
DEFINE(port)(0FFh)
IF (EQS(chip,186))			THEN (DEFINE(port)(0)) FI
IF (EQS(chip,8259))			THEN (DEFINE(port)(1)) FI
IF (EQS(chip,8259Cascade))	THEN (DEFINE(port)(2)) FI
IF (EQS(chip,8259Cascade2))	THEN (DEFINE(port)(3)) FI
IF (EQS(chip,DmaLPT))		THEN (DEFINE(port)(4)) FI
IF (EQS(chip,Ext8259))		THEN (DEFINE(port)(5)) FI
IF (port EQ 0FFh) THEN (Error(Unknown chip type 'chip')) FI
; Create rgHwIntDescInit.
; InitVector builds rgHardwareIntDesc, InitIoAddr builds mpTyDevMask.
	DW tyDev
	DW port
	DW bit
IF (EQS(wMem,0)) THEN (
	DW	0
) ELSE (
	IF (NOT *IsDef(wMem)) THEN (
		EXTRN wMem: WORD
	) FI
	DW OFFSET DGroup:wMem
) FI
	DW iInt
IF (EQS(entry,NIL)) THEN (
	DD	0
) ELSE (
	IF (NOT *IsDef(entry)) THEN (
		HwIntDescInitSeg ENDS
		Data ENDS
		EXTRN entry: FAR
		Data SEGMENT BYTE PUBLIC 'DATA'
		HwIntDescInitSeg SEGMENT BYTE PUBLIC 'MEMORY'
	) FI
	DD entry
) FI
	DW sStack
; fEnable as described in SysGen.asm is really bAttributes:
;    bit 1 = early EOI
;    bit 0 = interrupts enabled
IF (EQS(attr,CLI)) THEN (
	DB 0
) ELSE (
	IF (EQS(attr,STI)) THEN (
		DB 1
	) ELSE (
		DB attr
	) FI
) FI
DEFINE(m_oHwInt)(EVAL(m_oHwInt+sHwIntDescInit))
DEFINE(m_cHwInt)(EVAL(m_cHwInt+1))
HwIntDescInitSeg ENDS
)
; Fills in rgHwIntTableDesc(i).cHwIntDescInit for last table.
*DEFINE(EndHardwareInterruptTables)(
	DW m_cHwInt
)

$EJECT
*DEFINE (RequestFileName(name))()

;
; This macro sets counters for resident tables, data, and then reserves the OsTable.
;
*DEFINE(ResidentDataBoundry(size))(

if(not ctosp)then(
sMediatedIntTable EQU maxMedInterruptType+1
PUBLIC intSwtbl, sIntSwtbl
sIntSwtbl	DW sMediatedIntTable
IntSwTbl	DW cwIntSwTblEntry*sMediatedIntTable DUP (0)
)fi
rgOsTable	DB size DUP(0)
EVEN
endOsTable	DW 0
)

$EJECT
;
; Test definition of m_SysExchX (internal macro)
;
*DEFINE (TestSysExch(exch))(TestSymbol(Pass1eval(exch)))
*DEFINE (TestSymbol(Postfix))(*Isdef(m_SysExchPostfix))
*DEFINE (MakeSysExch(exch))('
SET(m_SysExchPass1eval(exch),exch)' value is not used, only isdef checks
)
;
; Assign a System Exchange
;
*DEFINE (AssignSysExch(exch,name))('
IF (TestSysExch(exch)) THEN (Error(Duplicate Sys Exch Defexch)'
)ELSE(MakeSysExch(exch)'
m_valname EQU exch
NameSysExch(exch,name)'
IF(exch GT m_SysExch)THEN('
SET (m_SysExch,exch)'
)FI)FI)
;
; Alloc a System Exchange, expands as a constant
;
*DEFINE (SysExch)('
WHILE(TestSysExch(m_ExchLast))(SET(m_ExchLast,m_ExchLast+1))'
MakeSysExch(m_ExchLast)'
IF(m_ExchLast GT m_SysExch)THEN('
SET (m_SysExch,m_ExchLast)'
)FI' This next line expands to the actual exchange, intended for DW arg.
m_ExchLast)
;
; Alloc a System Exchange, set word variable
;
*DEFINE (AllocSysExch(name))('
m_valname EQU SysExch
xxTempname label byte
ORG OFFSET name
DW m_valname
ORG OFFSET xxTempname
NameSysExch(m_valname,name)
)
;
; Name a System Exchange
;
; 81689 BF change class name from OEMSeg to MEMORYcoed ala IrfSeg
; for automatic discard after init
;
oSbExchSeg	SEGMENT WORD PUBLIC 'memory'
PUBLIC rgOSbExch
rgOSbExch	LABEL WORD	;offsets to Sbs, by exch , index 0 is limit of array
oSbExchSeg	ENDS

sbExchSeg	SEGMENT BYTE PUBLIC 'memory'
rgSbExch	LABEL BYTE	;compact array of Sbs
sbExchSeg	ENDS

DbgGroup Group oSbExchSeg, sbExchSeg

*DEFINE (NameSysExch(exch,name))('
sbExchSeg SEGMENT
sbExcheval(exch) EQU OFFSET $
DB 0
DB 'debl(name)'
sbExchNext EQU OFFSET $
ORG sbExcheval(exch)
DB sbExchNextsbExcheval(exch)1
ORG sbExchNext
sbExchSeg ENDS

oSbExchSeg SEGMENT
IF(m_oSbExchLast LE exch) THEN('
oSbExchNext EQU OFFSET $
ORG OFFSET rgOSbExch
DW	exch
ORG oSbExchNext
)FI'
WHILE(m_oSbExchLast LE exch)('
oSbExcheval(m_oSbExchLast) DW 0
SET(m_oSbExchLast,m_oSbExchLast+1)'
)'
oSbExchNext EQU OFFSET $
ORG OFFSET oSbExcheval(exch)
DW dbgGroup:sbExcheval(exch)
ORG oSbExchNext
oSbExchSeg ENDS
)


$EJECT

*DEFINE(InitRunFile(rgbRunFile, attr)) LOCAL sbSpec (

IrfStringSeg SEGMENT BYTE PUBLIC 'MEMORY'
sbSpec DB LEN(rgbRunFile), 'rgbRunFile'
IF (cIrf LT 2) THEN (
DB 92LEN(rgbRunFile) DUP (0)
)FI
IrfStringSeg ENDS

IrfSeg SEGMENT PARA PUBLIC 'MEMORY'
DW InitGroup:sbSpec
IrfSeg ENDS

IF (LEN(attr) NE 0) THEN (
DATA SEGMENT BYTE PUBLIC 'DATA'
PUBLIC iInitRunattr
iInitRunattr DW cIrf
Data ENDS
)FI
SET(cIrf,cIrf+1)
)

*DEFINE(InitRunFilePassword(password)) (

DATA SEGMENT BYTE PUBLIC 'DATA'
PUBLIC sbInitRunPswd
sbInitRunPswd DB LEN(password), 'password'
DATA ENDS

SET(cIrf, 0) 
IrfSeg SEGMENT PARA PUBLIC 'MEMORY'
IrfSegStart LABEL BYTE
IrfSeg ENDS
IrfStringSeg SEGMENT BYTE PUBLIC 'MEMORY'
IrfStringSeg ENDS
InitGroup GROUP IrfSeg, IrfStringSeg
)

*DEFINE(InitRunFileEnd) (
IrfStringSeg SEGMENT BYTE PUBLIC 'MEMORY'
IrfEnd LABEL BYTE
IrfStringSeg ENDS
DATA SEGMENT BYTE PUBLIC 'DATA'
; Boot chainsequence variables 
PUBLIC prgoSbInit, cbInitRunSeg
PUBLIC iInitRun, iInitRunLast
PUBLIC exitRunFilePrio, fInitExit, fDumpOccurred
iInitRun DW 0
iInitRunLast DW cIrf1
cbInitRunSeg DW OFFSET InitGroup:IrfEnd
prgoSbInit DD InitGroup:IrfSegStart
exitRunFilePrio DB 80h
fInitExit DB 0FFh
fDumpOccurred DB 0
DATA ENDS
)

*Define(DefaultDebugPort(Proc,bPort))(
Public rgbDefaultProcessor,DefaultDBGPort
rgbDefaultProcessor DB 'Proc'
DefaultDBGPort  DB 'bPort'
EVEN
)

$EJECT
*Define(ScratchVolumeSpec(name))(
PUBLIC sbScratchVolumeSpec
sbScratchVolumeSpec DB LEN(Name), 'Name'
                    DB EVAL(12LEN(Name)) DUP (0)
EVEN
)

*Define(DefaultCnfgFile(file))(
PUBLIC	cbDefaultConfigFile, rgbDefaultConfigFile
rgbDefaultConfigFile DB 'file'
                     DB 0   ; Used to pass cbConfigFileName to other boards.
cbDefaultConfigFile  DW Len(file)
EVEN
)

*Define(ConfigurationFile(name , password))(
CONST SEGMENT WORD PUBLIC 'DATA'
PUBLIC sbConfigFileSpec, sbConfigFilePswd
sbConfigFileSpec DB LEN(Name),'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbConfigFilePswd DB LEN(Password),'Password'
                  DB EVAL(12LEN(password)) DUP (0)
CONST ENDS
EVEN
)
*Define(WsConfigurationFile(name))(
PUBLIC sbWsConfigFileSpec
sbWsConfigFileSpec DB LEN(Name),'Name'
EVEN
)
*Define(HwConfigurationFile(name))(
PUBLIC sbHwConfigFileSpec
sbHwConfigFileSpec DB LEN(Name),'Name'
EVEN
)
*Define(NlsFileSpec(name , password))(
PUBLIC sbNlsFileSpec, sbNlsFilePassword
sbNlsFileSpec DB LEN(Name),'Name'
sbNlsFilePassword DB LEN(Password),'Password'
EVEN
)

*Define(WsNLSFileSpec(name))(
PUBLIC sbWsNLSFileSpec
sbWsNLSFileSpec DB LEN(Name),'Name'
EVEN
)

*Define(NlsKbdFileSpec(name , password))(
PUBLIC sbNlsKbdFileSpec, sbNlsKbdPassword
sbNlsKbdFileSpec DB LEN(Name),'Name'
sbNlsKbdPassword DB LEN(Password),'Password'
EVEN
)

*Define(WsNlsKbdFileSpec(name))(
PUBLIC sbWsNlsKbdFileSpec
sbWsNlsKbdFileSpec DB LEN(Name),'Name'
EVEN
)

$EJECT

*Define(SetSwapFileInfo)(
swapFileSize DW eval(cKSwapFile*1024),eval(cKSwapFile64)

; following 4 offsets are a structure known by page service
swapFileNameInfo LABEL BYTE
PUBLIC swapFileNameInfo
DW OFFSET DGroup:sbSwapFileTryEachPswd
DW OFFSET DGroup:sbSwapFileTryFirstPswd
DW OFFSET DGroup:sbSwapFileTryEach
DW OFFSET DGroup:sbSwapFileTryFirst

sbSwapFileTryEachPswd DB LEN(SwapFileTryEachPswd), 'SwapFileTryEachPswd'
sbSwapFileTryFirstPswd DB LEN(SwapFilePswd), 'SwapFilePswd'
sbSwapFileTryEach DB LEN(SwapFileTryEach), 'SwapFileTryEach'
                  DB EVAL(92LEN(SwapFileTryEach)) DUP (0)
sbSwapFileTryFirst DB LEN(SwapFile), 'SwapFile'
                  DB EVAL(92LEN(SwapFile)) DUP (0)

SET(ib, 0)
WHILE (NES(substr(SwapFileTryEach,ib+1,2),00) AND
		(ib NE LEN(SwapFileTryEach))) 
	(	SET(ib, ib+1)		)
IF (ib EQ LEN(SwapFileTryEach)) THEN (SET(ib, ib2))FI

ibSwapFileNumber DW ib
)


$EJECT
*Define(DefineXbusModule(id,cK,fRMOS,fMode3Master))(
IF (m_iModDescMax EQ 0) THEN (
PUBLIC rgModDesc
rgModDesc	LABEL	WORD
) FI
DB id
DW cK
DB fRMOS
DB fMode3Master
SET(m_iModDescMax, m_iModDescMax+1)
)


*Define(DefineLibSearchPath(pathname)) LOCAL oLink (
oLink EQU THIS BYTE
DW	OFFSET DGROUP:oLink + LEN(pathName) + 3
DB LEN(pathName)
DB 'pathName'
IF (NOT(*Isdef(oFirstPath))) THEN (
	Define(oFirstPath) (oLink)
	)FI
SET(oLastPath, oLink)
)

*Define(EndLibSearchPath) (
EndPathInfo LABEL BYTE
ORG oLastPath
DW 0	
ORG OFFSET EndPathInfo
PUBLIC pLibSearchPathHead
pLibSearchPathHead DD oFirstPath
)


;
; final  set counters in various tables, create gen table.
;

*DEFINE (Final)(

IF (PASS1) THEN (
; see InitKernel(KernalSetup) and Init82380 for the derivation.
SET(nExch, m_SysExch+1 + nUsrExchange)
SET(sMinosData, (nPcb*18) + (nExch*8) + (nExch*2) + (nMsgWait*10) +
	  (nPTiming*4) + (nUcb*42) + (nUcb*2) + (nPTiming*2) + (nSoftVec*12) +
	  (nPcb*22) + (nUcb*5) + (m_nOSProcDesc*2) + 4 + (nDmaIob*34) 
	  + sOsProcStacks 
	  + 1150 ; bus tables, null proc stack, misc
	  )
Out(
current sOsData sOsData
minimum recommended sOsData sMinosData
)
)FI


RtcRq(bellRq,0,0,0,1,64)'			; for beeper    '
IF(fKbdRes)THEN(
RtcRq(rqTimeKbd,0,0,0,1,63)'			; for repeat key'
RtcRq(rqTimeVid,0,0,0,1,63)'			; for Video timeout blank'
)FI
IF (ctosv) THEN (
RtcRq(trbGInfoSet,0,0,0,0,0)'			; for updating GInfoSeg'
)FI

m_temp label byte

org offset nOsProcDesc
DW	m_nOsProcDesc

org offset nSoftwareInt
DW	m_nSoftwareInt
org offset nExchg
DW	m_SysExch+1 + nUsrExchange
org offset userExchFirst
DW	m_SysExch+1

org offset m_temp

IF (m_nSoftwareInt EQ 0)        THEN (rgSoftwareIntDesc	label	byte) FI
IF (m_nInitProcHardware EQ 0)   THEN (rgInitProcHardware   label byte) FI
IF (m_nInitProcIntDisable EQ 0) THEN (rgInitProcIntDisable label byte) FI
IF (m_nInitProcIntEnable EQ 0)  THEN (rgInitProcIntEnable  label byte) FI
IF (m_nSetIntHandler EQ 0)      THEN (rgSetIntHandler  label byte) FI
If (m_nRgInitRtcRequest EQ 0) Then (rgInitRtcRequest Label Byte) FI
If (m_iModDescMax EQ 0) Then (rgModDesc Label Byte
PUBLIC rgModDesc) FI

EVEN
nRgInitRtcRequest	DW	m_nRgInitRtcRequest
nInitProcHardware	DW	m_nInitProcHardware
nInitProcIntDisable	DW	m_nInitProcIntDisable
nInitProcIntEnable	DW	m_nInitProcIntEnable
nSetIntHandler		DW	m_nSetIntHandler
PUBLIC nRgMassIo
nRgMassIo		DW	m_nRgMassIo
PUBLIC initSysDevNum
initSysDevNum		DW	IF (*IsDef(SysDevNum)) THEN (SysDevNum) ELSE (0FFFFh)FI

IF(fSrp) THEN (
PUBLIC	fCheckMem, fCheckEcc
fCheckMem		DB	fCheckMem
fCheckECC	 	DB 	fCheckEcc
)FI
PUBLIC iModDescMax
iModDescMax		DW	m_iModDescMax
PUBLIC fSFNM
fSFNM			DB	IF(fSpecialFullyNestedMode) THEN (0FFh) ELSE (0)FI

'  create gen structure
CreateGen
data ENDS
); end macro Final


$EJECT
;
; when an error is detected this macro is called
;
*DEFINE (m_Error (msg)) (SET(m_ErrorCount, m_ErrorCount + 1)
$SAVE LIST
;*** SYSGEN ERROR  msg
*****ERROR*****
$RESTORE
OUT(SYSGEN ERROR  msg
))
*DEFINE (Error (msg)) (m_Error (msg))

*DEFINE(Warning(str))(IF (PASS1) THEN (Out(
Warning  )out(str)) FI)


;
; end of file sysgen.mdf
;
DUP (0)
sbConfigFilePswd DB LEN(Password),'Password'
                  DB EVAL(12LEN(password)) DUP (0)
CONST ENDS
EVEN
)
*Define(WsConfigurationFile(name))(
PUBLIC sbWsConfigFileSpec
sbWsConfigFileSpec DB LEN(Name),'Name'
EVEN
)
*Define(HwConfigurationFile(name))(
PUBLIC sbHwConfigFileSpec
sbHwConfigFileSpec DB LEN(N