; CTOSVM 2.4
;
; COPYRIGHT (C) 1980, 1989 CONVERGENT INCORPORATED. ALL RIGHTS RESERVED.
; COPYRIGHT (C) 1980, 1989 UNISYS CORPORATION. ALL RIGHTS RESERVED.
;
; THIS SOFTWARE IS PROPRIETARY TO CONVERGENT INC. AND UNISYS CORP. AND IS NOT TO
; BE REPRODUCED, USED OR DISCLOSED EXCEPT IN ACCORDANCE WITH PROGRAM LICENSE OR
; UPON WRITTEN AUTHORIZATION OF THE PATENT DIVISION OF UNISYS CORPORATION.
;
; THIS PROGRAM IS FURNISHED UNDER A LICENSE RESTRICTING ITS USE SOLELY FOR THE
; OPERATION OF A DESIGNATED COMPUTER FOR A PARTICULAR PURPOSE.  TITLE TO AND
; OWNERSHIP OF THE PROGRAM, INCLUDING ITS SOURCE CODE, SHALL AT ALL TIMES REMAIN
; IN THE NAMES OF UNISYS CORPORATION AND CONVERGENT INCORPORATED.
;
;
;	2884, 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
;	21588  JM add rgUSeg stuff
;	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
;	11288  JM  group OemSeg in Dgroup so it gets relocated
;	82389  FW  Allow up to 24 dcbs.
;	9589   JM  version=2.4
;	92289  FW  Version must be 0B06h (not 0B04h)
;	10989  BA  added MaxXBlocksPerUser.
;	112289 FW  Fix bug which caused crash if more than 6 SCSI devices.
;
SET(TRUE,0FFh)
SET(FALSE,0)

IF (not(*Isdef(CTOSp))) THEN (Define(CTOSp)(0))FI

; If not specified, make the heap be 16 paragraphs (256 bytes)
IF (not(*Isdef(cParSCHeap))) THEN (Define(cParSCHeap)(10))FI


; Size of Control Block Definitions

sRcbIws        EQU 18
sRcbAws        EQU 18
xBlockHeaderSize EQU 32	; double header for new fields (was 18)
xBlockRqSize EQU 64  ;max size request block header that can fit in an XBlock

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

; Size of Variable Partition Blocks
if(ctosp)then(
sAsib	EQU	185
sArib	EQU	65
)else(
sAsib	EQU	93
sArib	EQU	49
)fi
sTib	EQU	15

; WsType definitions:

iwsStandAlone  EQU 0
iwsCluster     EQU 1
iwsMiniMaster  EQU 2
iwsIopMaster   EQU 3

aws210         EQU 4
aws220_240     EQU 5 ;AWS220, AWS230, AWS240
awsMaster      EQU 6

ngenCluster    EQU 7
ngen           EQU 8
ngenMaster     EQU 9

; HardwareType definitions

FPtype	EQU 10
TPtype	EQU 11
CPtype	EQU 12
SPtype	EQU 13
DPtype	EQU 14
RPtype	EQU 15


IF (not(*Isdef(WsType))) THEN (Define(WsType)(0))FI
Define(fIwsHardware)(0)
Define(fAwsHardware)(0)
Define(fNGenHardware)(0)
Define(fMFHardware)(0)
Define(fFP)(0)
Define(fTP)(0)
Define(fCP)(0)
Define(fSP)(0)
Define(fDP)(0)
Define(fRP)(0)
IF (WsType LE 3) THEN (Define(fIwsHardware)(0FFH))
ELSE(IF (WsType LE 6) THEN (Define(fAwsHardware)(0FFH))
ELSE(IF (WsType LE 9) THEN (Define(fNGenHardware)(0FFH))
ELSE(Define(fMFHardware)(0FFH)
IF (WsType EQ 10) THEN (Define(fFP)(0FFH))FI
IF (WsType EQ 11) THEN (Define(fTP)(0FFH))FI
IF (WsType EQ 12) THEN (Define(fCP)(0FFH))FI
IF (WsType EQ 13) THEN (Define(fSP)(0FFH))FI
IF (WsType EQ 14) THEN (Define(fDP)(0FFH))FI
IF (WsType EQ 15) THEN (Define(fRP)(0FFH))FI
)FI)FI)FI

;              ClusterConfig definitions:

standAlone     EQU 0
cluster        EQU 1
master         EQU 2

; initialize counters and flags
;
IF (clusterConfig EQ Master) THEN (
	IF (not(*Isdef(MaxErrorCount))) THEN (Define(MaxErrorCount)(15))FI
	IF (not(*Isdef(MaxTimeOutCount))) THEN (Define(MaxTimeOutCount)(10))FI
	If (fCP) Then (
		IF (not(*Isdef(TimeOutTicks))) THEN (Define(TimeOutTicks)(40))FI
	) ELSE (
		IF (not(*Isdef(TimeOutTicks))) THEN (Define(TimeOutTicks)(4))FI
	) Fi
	IF (not(*Isdef(TeleclusterTiming))) THEN (Define(TeleclusterTiming)(7))FI
	IF (not(*Isdef(nRepollActive))) THEN (Define(nRepollActive)(0))FI
)FI

IF (not(*Isdef(OSVersion))) THEN (Define(OSVersion)(0B06h))FI
IF (not(*Isdef(FS))) THEN (Define(FS)(0))FI

IF (not(*Isdef(fAwsPIT))) THEN (Define(fAwsPIT)(0))FI
IF (not(*Isdef(fDebugger))) THEN (Define(fDebugger)(1))FI
IF (not(*Isdef(fHDisks))) THEN (Define(fHDisks)(0))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(nUserNum))) THEN (Define(nUserNum)(nUcb))FI
IF (not(*Isdef(nNetUsers))) THEN (Define(nNetUsers)(0))FI
IF (not(*Isdef(nXBlockSmall))) THEN (Define(nXBlockSmall)(0))FI
IF (not(*Isdef(sMaxSmallRq))) THEN (Define(sMaxSmallRq)(0))FI
IF (not(*Isdef(nSectorPerXBlock))) THEN (Define(nSectorPerXBlock)(0))FI
IF (not(*Isdef(MaxXBlocksPerUser))) THEN (Define(MaxXBlocksPerUser)(4))FI
IF (not(*Isdef(nSoftVec))) THEN (Define(nSoftVec)(30+4*nUcb))FI
IF (not(*Isdef(nPartitions))) THEN (Define(nPartitions)(1))FI
IF (not(*Isdef(clusterTimeout))) THEN (Define(clusterTimeout)(10))FI
IF (clusterTimeout LT 2) THEN (Define(clusterTimeout)(2))FI
IF (not(*Isdef(fSpecialFullyNestedMode))) THEN (Define(fSpecialFullyNestedMode)(0FFh))FI
IF (not(*Isdef(fKbdRes))) THEN (Define(fKbdRes)(0FFh))FI
IF (not(*Isdef(nTryNewMaster))) THEN (Define(nTryNewMaster)(16))FI
IF (not(*Isdef(sParExitRunFile))) THEN (Define(sParExitRunFile)(3200))FI
Define(nAsib)(nUcb)
IF (not(*Isdef(nArib))) THEN (Define(nArib)(nAsib))FI
IF (not(*Isdef(fCheckMem))) THEN (Define(fCheckMem)(0))FI
IF (not(*Isdef(fCheckEcc))) THEN (Define(fCheckEcc)(0))FI
IF (not(*Isdef(nSwapFabs))) THEN (Define(nSwapFabs)(32))FI
IF (not(*Isdef(nUsrExchange))) THEN (Define(nUsrExchange)(20))FI
IF (not(*Isdef(nPTiming))) THEN (Define(nPTiming)(20))FI
Define(nMsgWaitReserve)(0)
If (Not(*Isdef(cSegAllocateMax))) Then (Define(cSegAllocateMax)(0FFFFh))FI'
If (Not(*Isdef(cbNameSpace))) Then (Define(cbNameSpace)(4096))FI'
If (Not(*Isdef(cbNameCompactionGoal))) Then (Define(cbNameCompactionGoal)(eval(cbNameSpace2)))FI'
If (Not(*Isdef(cDiskLogThreshold))) Then (Define(cDiskLogThreshold)(0))FI'

IF (fMFHardware) THEN (
If (not(*Isdef(wsTotal))) Then (Define(wsTotal)(1))FI
If (Not(*Isdef(sOutBuffer))) Then (Define(sOutBuffer)(128))FI
If (Not(*Isdef(sRouteArea))) Then (Define(sRouteArea)(300))FI
If (Not(*Isdef(sTermArea))) Then (Define(sTermArea)(20))FI
If (Not(*Isdef(sLineArea))) Then (Define(sLineArea)(20))FI
If (Not(*Isdef(nReqEnts))) Then (Define(nReqEnts)(10))FI
If (Not(*Isdef(nRespEnts))) Then (Define(nRespEnts)(10))FI
If (Not(*Isdef(sStatArea))) Then (Define(sStatArea)(4))FI
If (Not(*Isdef(nYblk))) Then (Define(nYblk)(4))FI
If (Not(*Isdef(nSectorPerYblk))) Then (Define(nSectorPerYblk)(5))FI
If (Not(*Isdef(nZblk))) Then (Define(nZblk)(28))FI
If (Not(*Isdef(sZblk))) Then (Define(sZblk)(180))FI
If (Not(*IsDef(Real186))) Then (Define(Real186)(0FFFFh))Fi
If (Not(*IsDef(nMountedDisks))) Then (Define(nMountedDisks)(10))Fi

If (Not(*IsDef(nAdapters))) Then (Define(nAdapters)(1))Fi

; The 64 (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 (fCP) Then (
    If (Not(*IsDef(nXblk))) Then (Define(nXblk)(5))Fi
    If (Not(*IsDef(sTpInBuf))) THEN (Define(sTpInBuf)(128))FI
    If (Not(*IsDef(sTpOutBuf))) THEN (Define(sTpOutBuf)(128))FI
    If (Not(*IsDef(sPtW0Buf))) THEN (Define(sPtW0Buf)(64))FI
    If (Not(*IsDef(sPtW1Buf))) THEN (Define(sPtW1Buf)(64))FI
    If (Not(*IsDef(sPtW2Buf))) THEN (Define(sPtW2Buf)(64))FI
    If (Not(*IsDef(sPtW3Buf))) THEN (Define(sPtW3Buf)(64))FI
    If (Not(*IsDef(sPtW4Buf))) THEN (Define(sPtW4Buf)(64))FI
    If (Not(*IsDef(sPtW5Buf))) THEN (Define(sPtW5Buf)(64))FI
    If (sPtW4Buf GT 128) THEN (SET (sPtW4Buf, 128))FI
    If (sPtW5Buf GT 128) THEN (SET (sPtW5Buf, 128))FI
) ELSE (
    If (Not(*IsDef(nXblk))) Then (Define(nXblk)(0)) Fi
) Fi

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

If (fFP) Then (
    If (Pass1) Then (
	If (not(*IsDef(nWinch))) Then (
	    Out (Define nWinch)
	) Else (
	    If ((nWinch LT 1) or (nWinch Gt 4)) Then (
		Out (nWinch must be in 1..4)
	    ) FI
	) FI
    ) FI
) Fi

If (fDP) Then (
    If (Pass1) Then (
	If (not(*IsDef(nWinch))) Then (
	    Out (Define nWinch)
	) Else (
	    If ((nWinch LT 1) or (nWinch Gt 6)) Then (
		Out (nWinch must be in 1..6)
	    ) FI
	) FI
    ) FI
) FI

If ((fFP) OR (fDP)) Then (
	If (Not(*IsDef(nRemoteUser))) THEN (Define(nRemoteUser)(160))FI
	If (Not(*IsDef(sMassIoRqQueue))) THEN (Define(sMassIoRqQueue)(20))FI
    ) Else (
	If (Not(*IsDef(nRemoteUser))) THEN (Define(nRemoteUser)(32))FI
	If (Not(*IsDef(sMassIoRqQueue))) THEN (Define(sMassIoRqQueue)(0))FI
) FI

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

if(ctosp)then(
SET (m_nSoftwareInt,  0)
SET (m_nHardwareInt,  0)
)else(
SET (m_nRawInt,       0)
SET (m_nMediatedInt,  0)
)fi
SET (m_ErrorCount,    0)
SET (nDcb,            0)
SET (m_nOsProcDesc,   0)
SET (m_nVirtualExch,  0)
SET (m_nRgInitRtcRequest, 0)
SET (m_nInitProcHardware, 0)
SET (m_nInitProcIntDisable, 0)
SET (m_nInitProcIntEnable, 0)
SET (m_nRequestFileNames, 0)
SET (m_typeMax, 0)
SET (m_nSysCommInt, 0)
SET (cascade8259, 0)
SET (m_nRgMassioDisp, 0)
SET (m_ExchLast, 1)
SET (m_SysExch, 1)
SET (m_nRemoteDmaRequests, 0)
SET (m_iModDescMax, 0)

SET (dcb0,0)   ; no dcbs defined initially
SET (dcb1,0)
SET (dcb2,0)
SET (dcb3,0)
SET (dcb4,0)
SET (dcb5,0)
SET (dcb6,0)
SET (dcb7,0)
SET (dcb8,0)
SET (dcb9,0)
SET (dcb10,0)
SET (dcb11,0)
SET (dcb12,0)
SET (dcb13,0)
SET (dcb14,0)
SET (dcb15,0)
SET (dcb16,0)
SET (dcb17,0)
SET (dcb18,0)
SET (dcb19,0)
SET (dcb20,0)
SET (dcb21,0)
SET (dcb22,0)
SET (dcb23,0)
IF(not(*isdef(nWinch))) THEN (Set(nWinch,0))FI
IF(not(*isdef(nFloppy))) THEN (Set(nFloppy,0))FI
IF(not(*isdef(nSCSI))) THEN (Set(nSCSI,3))FI
SET(FloppyUnitNum,0)
SET(HDiskUnitNum,0)
SET(SCSIunitNum,0)
SET(nRqNoRemoteTerm,0)

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

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

IF (NOT FS) THEN (' CTOS
OEMSeg SEGMENT PARA PUBLIC 'OEMSeg'
PUBLIC rgbOemSeg
rgbOemSeg DB 32 DUP (0)
OEMSeg ENDS
)FI
NameCommon SEGMENT PARA PUBLIC 'OEMSeg'
 DW 32
 DB 30 DUP (0)
NameCommon ENDS
const SEGMENT PUBLIC 'const'
const ENDS
data SEGMENT PUBLIC 'data'
IF (NOT FS) THEN (
DGroup GROUP Const, Data, OEMSeg, NameCommon
)ELSE(
DGroup GROUP Const, Data, NameCommon
)FI

PUBLIC userNumLast, userNumClstrLast, nNetUsers, NetServerData
PUBLIC pRgOUcb, pRgOExUcb
PUBLIC rgOsTable, endOsTable
PUBLIC sbScratchVolumeSpec
PUBLIC fLfsToMaster, vfAllowDirSlashes
PUBLIC cbNodeName,NodeName

IF (FS) THEN (
PUBLIC wVerBuff, fFsVerify
PUBLIC VerifyCode
PUBLIC maskVerifyCode, maskFPIndex
PUBLIC FsRqBuffer
PUBLIC sNmbHeap,sNmbCompactionGoal
PUBLIC cDiskLogThreshold

) ELSE (' CTOS
PUBLIC fSysChannelA, fSysChannelB
PUBLIC fSubsysChannelA, fSubsysChannelB
PUBLIC rgsbWsUserName, rgWsId,nWsAbortRq
PUBLIC pRgWsAbortRq, pRgChgUserNumRq, pRgTerminationRq, pRgSwappingRq
PUBLIC nWsAbortRq, nChgUserNumRq, nTerminationRq, nSwappingRq
PUBLIC contingencyLog
PUBLIC  ExchNetServer
PUBLIC userNumNetMin,userNumNetMax
PUBLIC nBytExchs, bitmapExchs, bitmapExchsSave, pBitmapExchsSave, userExchFirst
PUBLIC fGoingDown
if(ctosp)then(
PUBLIC rgSoftwareIntDesc, nSoftwareInt
PUBLIC rgHardwareIntDesc, nHardwareInt
)else(
PUBLIC rgRawIntDesc, nRawInt
PUBLIC rgMediatedIntDesc, nMediatedInt
)fi
PUBLIC intSwtbl, sIntSwtbl
PUBLIC nTicks, cFramesMax
PUBLIC nParDesc
PUBLIC wOSVersion
PUBLIC rgUcb,oRgOUcb,rgOUcb
PUBLIC oRgOExUcb
PUBLIC sBufOut, mBufOut
PUBLIC sExec
PUBLIC sbExitRunFileSpec, sbExitRunFilePswd, exitRunFilePrio
PUBLIC GraphicsInfo, eventControlBlock
PUBLIC rgUserReadCount
PUBLIC userNumKbd, userNumVid
PUBLIC pXlatTable, wXlatTableChksum, pUserXlatTable
PUBLIC pRgSdInit, nSdInit, fInitExit, exitRunFilePrioSave
PUBLIC exchSched,exchSchedPocket
PUBLIC rgCannotOpenSwapFile, cbCannotOpenSwapFile
PUBLIC logCannotLoadNlsFile
PUBLIC nSwapFabs
PUBLIC rgWakeupRq, cWakeUpRq
PUBLIC xBusWindowSize, fHighSpeed
PUBLIC sXbMax
)FI


IF (fMFHardware) THEN (' MF publics
PUBLIC	fMasterFP
Public	bMySlot, bMyLine, bMasterFpCpuId
Public	bMasterCpCpuId

IF (NOT FS) THEN (' CTOS
Public	rgRemoteDmaRequest, nRemoteDmaRequest
Public	bConsoleSlot, bConsolePort, pConsoleObuf
Public	fSysChannelC, fSysChannelD, fSubsysChannelC, fSubsysChannelD
Public  Mask186
Public	sYblk, nYblk, pYblkListHead
Public	sZblk, nZblk, pZblkListHead
PUBLIC  nDct
PUBLIC  fSrpUp
PUBLIC	rgbTypeTable, rgbXpChar, srgbTypeTable
Public	maxAdapters, Adt
Public	nUserNum, rgLocalUserNum
Public  ibBufOutTake, ibBufOutPut, rgbBufOut, mBufOut
Public	fBufOutOverflow
If ((fFp) OR (fDp)) Then (
    Public maxDevMounted, nDevMounted, rgFpMasterMountTable
) Fi
PUBLIC	cbPriParName, rgPriParName
PUBLIC	timeSliceLb, timeSliceHb, fTimeSlice

	; Statistics Stuff

Public	pStat, pDiskStat, pProcStat, pExchStat, pIccStat
Public	sStat, sDiskStat, sProcStat, sExchStat, sIccStat
PUBLIC	nMinIOB, nAvailIOB, nMinY, nMinZ, nAvailY, nAvailZ
PUBLIC	nIccIn, nIccOut, nIccSkip, nLocRead, nLocWrite, nLocSeeks
Public	nRemRead, nRemWrite, nRemSeeks, nProcTick, nExchIn
Public	nYblkCopy, nParaIn, nParaOut, nInitY, nInitZ, nInitIOB
Public	nIobUsed

IF (fTP OR fCP) THEN (
	PUBLIC userNumChannelA, userNumChannelB, userNumChannelC, userNumChannelD
	PUBLIC pbExtCntlComReg
)FI
IF (fCP) THEN(
    PUBLIC  wsUserNumLast, rgWsLocalUserNum
    Public  rgfSrpClock, rgNoWsLine
    Public  nLcb, rgcTimeDelay, prgRcb, rgcMaxRqBlk, rgfLineEn
) Else (
    PUBLIC      cDelayDisc
) FI
)FI


) ELSE (' Workstation publics
IF (FS) THEN (
PUBLIC fFloppyCheck
PUBLIC fF0IllegallyRemoved,fF1IllegallyRemoved
IF (fFloppyCheck) THEN(
PUBLIC  cbReinsertFloppyMsg,ReinsertFloppyMsg,oReinsertMsgVolName
PUBLIC	oReinsertMsgUnitNum,SaveVideoBuf,RemovedF0VolName,RemovedF1VolName
PUBLIC  RemovedF0UserCount,RemovedF1UserCount,RemovedF0CreateDT
PUBLIC	RemovedF1CreateDT,RemovedF0ModifyDT,RemovedF1ModifyDT
)FI
PUBLIC qbAllocateMax

) ELSE (' CTOS
PUBLIC oRgUserReadCount
PUBLIC oRgUserWaitCount
PUBLIC saGraphicsBoard, fGraphicsBoard, mbIOPort, bGraphicsPort
IF (wsType NE aws210) THEN (
PUBLIC userNumChannelA, userNumChannelB
)FI
PUBLIC pAckInBuf, pAckOutBuf
if(not ctosp)then(
PUBLIC pDmaBuf
)fi
PUBLIC pMouseData
PUBLIC extCntlRegAws
PUBLIC rgCrashMsg, cbRgCrashMsg, rgLastCrashMsg, cbRgLastCrashMsg
PUBLIC rgClusterMsg, cbRgClusterMsg, rgExitFileError, cbRgExitFileError
PUBLIC rgInitError, cbRgInitError
PUBLIC rgInitError, cbRgInitError, rgCheckConfig, cbRgCheckConfig
PUBLIC rgCheckConfigPswd, cbRgCheckConfigPswd
PUBLIC fAwsPIT, RtcTpb

PUBLIC rgWsLocalUserNum
PUBLIC wsUserNumLast
PUBLIC pSysTime, pRgPrgNetRouting, pRgRcMax, pBootBlock
PUBLIC iLineCurrent,iColCurrent,sMapCurrent,sarCurrent,userNumVdm
PUBLIC fProtected
PUBLIC rgModDesc, iModDescMax
)FI
)FI' WS publics

; The following public's are used only for initialization

PUBLIC nOSProcDesc
PUBLIC rgOSProcDesc
PUBLIC nInitProcHardWare,   rgInitProcHardWare
PUBLIC nInitProcIntDisable, rgInitProcIntDisable
PUBLIC nInitProcIntEnable,  rgInitProcIntEnable
PUBLIC nRgInitRtcRequest, rgInitRtcRequest
PUBLIC gen
PUBLIC Config, wsType, osType, nPcb, nExchg, nMsgWait
PUBLIC nPTiming, nUcb
PUBLIC saSemiLowest, saSemiHighest, saTempLowest, saTempHighest, saEndMemory
PUBLIC plaEndMemory
PUBLIC hardwareType, clusterConfig, fNoFileSystem, fCommIop, fMulpar
PUBLIC nIob, nFcb, nFub	; Init code sets these in config block for FS to see.

IF (FS) THEN (
PUBLIC nVhb
PUBLIC nRgMassioDisp, rgMassioDisp
PUBLIC initSysDevNum

) ELSE (' CTOS
if(ctosp) then(
public nGDTSlots
public sgFreeHead
public sgFreeTail
public sgTssIntLast
public isgGdtCallGateFirst
public nGdtCallGates
public pRgoGdtLink
public f386
public f386Finger
public rgIpcAliasHead
public pRgSgLdt
public pRgSwapMode
)fi

public sSCHeap

PUBLIC orgPcb
PUBLIC rgExchReal, srgExchReal
PUBLIC nRequestFileNames, rgRequestFileNames
PUBLIC sbConfigFileSpec, sbConfigFilePswd, configFilePrio, sbWsConfigFileSpec
PUBLIC sbInitFileSpec, sbInitFilePassword, initFilePrio
PUBLIC sbNlsFileSpec, sbNlsFilePassword
PUBLIC sbInstallVdmSpec, sbInstallVdmPswd
PUBLIC sbInstallKbdSpec, sbInstallKbdPswd
PUBLIC sbInstallMathSpec, sbInstallMathPswd
PUBLIC sbExtCrashDumpSpec, sbExtCrashDumpPswd
PUBLIC sbOEM1Spec, sbOEM1Pswd
PUBLIC sbOEM2Spec, sbOEM2Pswd
PUBLIC sbOEM3Spec, sbOEM3Pswd
PUBLIC sbOEM4Spec, sbOEM4Pswd

IF(fMFHardware)THEN(
PUBLIC	nChgUserNumRq
PUBLIC	fCheckMem, fCheckEcc
PUBLIC	nXbuf, sXBData, nXBlock, nXBlockSmall, sSmallXBlock
PUBLIC  nSectorPerXBlock, XBlockHeaderSize
Public  pbInitFileName, cbInitFileName
If (fCP) Then (
    Public nT0QBlk, nPTTotal
    Public nsPtW0, nsPtW1, nsPtW2, nsPtW3, nsPtW4, nsPtW5, sPtHdr, sTpInHdr
    Public rgTpInBuffers, rgTpOutBuffers, sTpOutHdr
    Public nsTpInBuf, nsTpOutBuf
) FI
If (fTP) Then (
    Public sTpInHdr, sTpOutHdr
    Public rgTpInBuffers, rgTpOutBuffers
    Public nsTpInBuf, nsTpOutBuf
) Fi

)ELSE(' Workstations
PUBLIC bGraphicsPort
PUBLIC fSFNM
)FI
)FI' CTOS

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

EVEN
Config LABEL WORD
wsType			DB wsType
osType			DB 1	;Resident, not swapping
saSemiLowest	DW 0
saSemiHighest	DW 0
saTempLowest	DW 0
saTempHighest	DW 0
if(not ctosp)then(
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 nIob
nFcb			DW nFub
nVhb			DW nVhb
nUcb			DW nUcb
nFub			DW nFub
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

IF(fMFHardware) THEN (
fMasterFP		DB	0
bMasterFpCpuId		Db	?
bMySlot			Db	?
bMasterCpCpuId		Db	?
                                   
nParDesc		DW	nPartitions

; End of system configuration block
bMyLine			db	?
Even

)FI' Megaframe

IF (NOT FS) THEN (' CTOS

IF(fMFHardware) THEN (
rgLocalUserNum		Dw	0FFFFh
			Dw	0
			Dw	Eval(nUcb+nRemoteUser) Dup (0FFFFh)
nUserNum		Dw	3    

; nRemoteUser is the number of remote user occupying a slot in rglocalusernum 
; table when fetchlocalusernum.
 
ntotaluser		Dw	nUcb + nRemoteUser

oRgOUcb DW DGROUP:rgOUcb
oRgOExUcb DW 0
oRgPcb    DW 0

userNumVid DW 1	; dummy for GetpStructure
userNumKbd DW 1

) ELSE (' Workstation
	DB 0 ; alignment
nParDesc DW nPartitions
oRgOUcb DW DGROUP:rgOUcb
oRgOExUcb DW 0
;	These two userNums are a structure. They are in sysConfig so that the installable video system service can access them.
IF(fVarpar) THEN (
userNumVid DW 2
userNumKbd DW 2
) ELSE (IF (FMulPar) THEN (
userNumVid DW 1
userNumKbd DW 1
) ELSE (
userNumVid DW 0
userNumKbd DW 0
)FI )FI
oRgPcb    DW 0
oRgUserReadCount DW DGROUP:rgUserReadCount  ;Used by InitVam
oRgUserWaitCount DW DGROUP:rgUserWaitCount  ;Used by InitVam

fSysChannelB DW 0   
fSubsysChannelA DW 0
fSubsysChannelB DW 0

IF(fVarpar) THEN (
	DW DGROUP:rgsgAsib ; used by debugger, debugfile
	DW sAsib
	DD ResumeTask	 ; used by debugfile
	)FI

; End of system configuration block

)FI' Workstation

fProtected DB IF(CTOSp) THEN (0FFh) ELSE (0)FI
if (ctosp) then(
f386 db 0
f386Finger db 0
nGdtSlots dw nGdtSlots
sgTssIntLast dw 0
sgFreeHead dw 0
sgFreeTail dw 0
isgGdtCallGateFirst dw 0
nGdtCallGates dw 0
pRgoGdtLink dd 0
rgIpcAliasHead DW nUcb DUP(0)
plaEndMemory DD 0
pRgSgLdt dd 0
pRgSwapMode dd 0
)FI


sSCHeap dw cParSCHeap*16

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
iLineCurrent DB 0FFh
iColCurrent DB 0FFh
sMapCurrent DW 0
sarCurrent	DW 0
userNumVdm	DW 0

sUcb EQU 95
rgUcb DB nUcb*sUcb DUP(0)
EVEN
wOSVersion DW OSVersion
rgOUcb DW nUcb DUP(0)

; 2.4  Allocated user number support.
$INCLUDE(SysGenUVA.mdf)
; end 2.4

)FI' CTOS, not FS

nOsProcDesc DW 0	; for stack check code

; Space is always allocated since switch can be set at boot time
;  (On protected mode OS's, the space is not significant and can
;   be used for other useful purposes if fFsVerify is false.)
IF (FS) THEN (
EVEN
wVerBuff LABEL WORD
DW 256 DUP (0)
IF (fVerifyFileStruct) THEN (
fFsVerify DW 0FFFh
)ELSE (
fFsVerify DW 0
)FI

VerifyCode DW ?
IF (fMFHardware) THEN (
maskVerifyCode DW 06000h
maskFPIndex DW 01C00h
) ELSE(
maskVerifyCode DW 7000h
maskFPIndex DW 0
)FI

fFloppyCheck DB fFloppyCheck
fF0IllegallyRemoved DB 0
fF1IllegallyRemoved DB 0

FsRqBuffer DB 30 DUP(0)

qbAllocateMax DW 0,cSegAllocateMax
sNmbHeap DW cbNameSpace
sNmbCompactionGoal DW cbNameCompactionGoal

cDiskLogThreshold DW cDiskLogThreshold

)FI' FS

; 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
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
pRgSwappingRq DD 0
nSwappingRq DW  0
exchNetServer DW 0
cbNodeName DB 0
nodeName DB 12 DUP(0)
IF (FS) THEN (' Declare empty table
pRgPrgNetRouting DD ?
pRgRcMax DD ?
pBitmapExchsSave DD ?
userExchFirst DW ?
pSysTime DD ?
pBootBlock DD ?
pRgOUcb DD ?
pRgOExUcb DD ?
) ELSE (' CTOS
EXTRN rgPrgNetRouting: FAR
EXTRN rgRcMax: FAR
pRgPrgNetRouting DD DGroup:rgPrgNetRouting
pRgRcMax DD DGroup:rgRcMax
pBitmapExchsSave DD DGroup:bitmapExchsSave;
userExchFirst DW ?
EXTRN SysTime:WORD
pSysTime DD DGroup:sysTime
EXTRN BootBlock:WORD
pBootBlock DD DGroup:BootBlock
pRgOUcb DD DGroup:rgOUcb
pRgOExUcb DD 0    ;Set by InitFile
;EXTRN rgCommRawVector: WORD
; was: pRgCommRawVector DD DGroup:rgCommRawVector
userNumNetMin DW 0	; Set by InstallNet request.
userNumNetMax DW 0
IF(fMFHardware) THEN (
pDmaBuf			DD	0
pAckOutBuf		DD	0
pAckInBuf		DD	0
			DW	0FFFFH
			DW	0
) ELSE (' Workstation
if(ctosp)then(
obsoleteUnused2 DD 0
pAckOutBuf DD 0
pAckInBuf DD 0
)else(
pDmaBuf DD dmaBuf
pAckOutBuf DD ackOutBuf
pAckInBuf DD ackInBuf
)fi
EXTRN mouseData: WORD
pMouseData DD DGroup:mouseData
)FI'
EXTRN rgPrgLocalServiceCode: WORD
prgPrgLocalServiceCode DD DGroup:rgPrgLocalServiceCode
; 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.

xBusWindowSize DW 0 ; = 0, 96H, 224H, or 480H
fHighSpeed DB 0

; End of Configuration variables

sXBMax		DW	XBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)

IF (fTP OR fCP OR (NOT fMFHardware AND (wsType NE aws210))) THEN (
fSysChannelA DW 0
PUBLIC rgCommLine
rgCommLine      DD 9 DUP(0)
                DW 4 DUP(0)
userNumChannelA DW 0FFFFh
				DW 0000h
if(ctosp)then(
			    DW 0
				DB 0	;fDma
)fi

                DD 9 DUP(0)
                DW 4 DUP(0)
userNumChannelB DW 0FFFFh
				DW 0001h
if(ctosp)then(
			    DW 0
				DB 0	;fDma
)fi

IF (fTp) THEN(
                DD 9 DUP(0)
                DW 4 DUP(0)
userNumChannelC DW 0FFFFh
				DW 0002h
if(ctosp)then(
			    DW 0
				DB 0	;fDma
)fi

                DD 9 DUP(0)
                DW 4 DUP(0)
userNumChannelD DW 0FFFFh
				DW 0003h
if(ctosp)then(
			    DW 0
				DB 0	;fDma
)fi
)FI)FI'

IF (fCp) THEN(
userNumChannelC LABEL WORD
userNumChannelD LABEL WORD
)FI

IF (fTP OR fCP) THEN (
pbExtCntlComReg DD	bExtCntlComReg
bExtCntlComReg  DB   (0)
)FI

; one DmaAddr structure is needed for each communications port that supports
; comm dma.  For each pair of channels, one CommDmaEnable word is required.
;
if(ctosp)then(
PUBLIC rgDmaAddr
rgDmaAddr       DW 13 DUP(0)		; channel 1
                DB  6 DUP(0)
                DW  2 DUP(0)
                DW 13 DUP(0)		; channel 2
                DB  6 DUP(0)
                DW  2 DUP(0)

PUBLIC rgCommDmaEnable
rgCommDmaEnable	DB	(0)
)fi

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

nTicks  DB IF(fMFHardware) THEN (10)
	ELSE(IF (lineHZ EQ 60) THEN (6)
	ELSE (IF (fNGenHardware) THEN (4)
	ELSE (5) FI) FI) FI
cFramesMax DB nFrames
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
SET(nBytesUsrExch, EVAL((nUsrExchange+7)8))
bitmapExchs DB nBytesUsrExch DUP (0)
bitmapExchsSave DB nBytesUsrExch DUP (0)
EVEN
contingencyLog DW sContingencyLog DUP (0)
nBytExchs DW nBytesUsrExch
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)
ibBufLEDsPut DW 0
ibBufLEDsTake DW 0
maskiBufLED DW sIBusBuffer1
PUBLIC rgbBufLEDs, ibBufLEDsPut, ibBufLEDsTake, maskiBufLED

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

fAwsPIT  DB fAwsPIT
IF(fAwsPIT)THEN(
RtcTpb  DW 16 DUP (?)
)ELSE(
RtcTpb LABEL WORD
)FI

PUBLIC clusterTimeout
clusterTimeout DW (clusterTimeout+1)2 ;each unit of clusterTimeout is 2sec.

pXlatTable			DD 0
wXlatTableChksum	DW 0
pUserXlatTable		DD 0

nSwapFabs			DW nSwapFabs

IF(fVarPar)THEN('leave space for AllocSysExch to fill
exchSched	DW	?
exchSchedPocket	DW	?
)ELSE(
exchSched LABEL WORD
exchSchedPocket LABEL WORD
)FI

; Boot chainsequence variables 
pRgSdInit DD ?
nSdInit DW 0
fInitExit DB 0FFh

;****************************************************************************
; Parameters for all cluster workstations
;****************************************************************************
IF (clusterConfig EQ 1) THEN (
; This is the number of times to retry sending XID to the master before we decide it must be an old master. It takes longer for a workstation to come up if this number if large. It should be around 10 for an NGen workstation on a cluster of 40 workstations.
PUBLIC nTryNewMaster 
nTryNewMaster DB nTryNewMaster
)FI
IF (NOT (clusterConfig EQ 1)) THEN (
PUBLIC nTryNewMaster 
nTryNewMaster DB 0
)FI

;****************************************************************************
; Parameters for all masters
;****************************************************************************

;
EVEN
IF ((wsType EQ iwsMiniMaster) OR (wsType EQ iwsIopMaster) OR (wsType EQ awsMaster)  OR (wsType EQ NGenmaster) OR (fCP)) THEN (
PUBLIC nRepollActive
SET(nWsUserNum, nUserNumnPartitions)
IF (nWsUserNum EQ 0) THEN (Define(nWsUserNum)(WsTotal + 3))Fi 
wsUserNumLast  DW nWsUserNum1
rgWsid   DW nWsUserNum DUP (0)
rgWsLocalUserNum DW nWsUserNum DUP (0)
nRepollActive	DB	nRepollActive
) ELSE(
wsUserNumLast  LABEL WORD
rgWsid   LABEL WORD
rgWsLocalUserNum LABEL WORD
 DW 0
) FI

;****************************************************************************
; Parameters for the multipartition OS
;****************************************************************************
;
IF (fMulPar) THEN (
PUBLIC oExUcb
PUBLIC saMaxPartition
PUBLIC cbPriParName, rgPriParName, cbSysSvcParName, rgSysSvcParname
PUBLIC timeSliceLb, timeSliceHb, fTimeSlice
PUBLIC ContextState
PUBLIC ContextStatus
PUBLIC rgpVidMemLine
PUBLIC rgcRq
PUBLIC rgDeltaPriority
PUBLIC rgwTwoDigit
IF (fVarPar) THEN (
PUBLIC rgsgAsib
;PUBLIC AsibShared
PUBLIC nAsib, nArib
PUBLIC cbAsib
PUBLIC cbArib
PUBLIC sbSwapFileTryFirst
PUBLIC sbSwapFileTryFirstPswd
PUBLIC sbSwapFileTryEach
PUBLIC sbSwapFileTryEachPswd
PUBLIC ibSwapFileNumber
PUBLIC swapFileSize
)FI

EVEN
oExUcb  DW 0
saMaxPartition DW 0
timeSliceLb DB lbTimeSlicePriority
timeSliceHb DB hbTimeSlicePriority
fTimeSlice DB fTimeSliceEnable
ContextStatus DB nPartitions DUP(0)
rgcRq DB nPartitions DUP(0) ; Just after ContextStatus
ContextState DB nPartitions DUP(0)	; Just after rgcRq
rgDeltaPriority DB nPartitions DUP (0)
rgUserReadCount DB nPartitions DUP (0)
rgUserWaitCount DB nPartitions DUP (0)
rgpVidMemLine LABEL DWORD ' Used as global in Sp, by partition in Mp.


;rgWakeUpRq
;  Request codes which cause the scheduler to try to swap in when
;  responded to with ercSwapping
cWakeUpRq	DW 2
rgWakeUpRq	LABEL WORD
 DW 0, 0

rgwTwoDigit LABEL WORD
SET(m_Ones,0)'
SET(m_Tens,0)'
Repeat(nUcb+1)(' Generates 00 to nUcb
' 2char string with tens in low byte of word
 DB 'SUBSTR(m_Tens,1,1)','SUBSTR(m_Ones,1,1)'
SET(m_Ones,m_Ones+1)'
IF(m_Ones EQ 10) THEN (SET(m_Ones,0)SET(m_Tens,m_Tens+1))FI'
)

IF (fVarPar) THEN (
rgsgAsib LABEL WORD
	DW nAsib DUP(0)
;AsibShared LABEL WORD
;	DB sAsibShared DUP(0)
nAsib  DW nAsib
nArib  DW nArib
cbAsib DW sAsib
cbArib DW sArib
)FI

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

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



) ELSE (
;*********************************************
; Variables used only for SinglePartition OS
;*********************************************
PUBLIC Ovly15, rgpVidMemLine
PUBLIC rgBBufOut
PUBLIC prgPcb, cPcb, cUcb
prgPcb LABEL WORD
rgUserReadCount LABEL WORD
rgUserWaitCount LABEL WORD
cPcb LABEL WORD
cUcb LABEL WORD
EVEN
IF (wsType LT aws210) THEN (
rgpVidMemLine DD 34 DUP (?)
)ELSE (
rgpVidMemLine DD 29 DUP (?)
)FI
rgbBufOut DB sKbdBuffer DUP (0)
;Define Ovly15 so that we can use the same version of FsRes for Mp.
Ovly15 LABEL DWORD
) FI

;****************************************************************
;  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     
;****************************************************************

IF(NOT fMFHardware) THEN (

; 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

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

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

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

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

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

)FI' NOT MF

; The following is the message written into the log file by the OS if 
; the swap file cannot be accessed. The maximum length for this message
; is 72 bytes.
cbCannotOpenSwapFile DB 43
rgCannotOpenSwapFile DB 'The swap file cannot be opened, erc =     '

; The following is the message written into the log file by the OS if 
; the nls file cannot be loaded.  
logCannotLoadNlsFile DW 0FFF7h
cbCannotLoadNlsFile DW 42
rgCannotLoadNlsFile DB 'The nls file cannot be loaded, erc =      '

IF (fMulpar) THEN (
; The following is the name given to the primary partition of a multi
; partitioned OS.

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

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

cbSysSvcParName DB 12  ; length of the text string
rgSysSvcParName DB 'SysService00'
) FI
EVEN

;****************************************************************************
; Variables common to all IWS Operating Systems
;****************************************************************************
IF (wsType LT aws210) THEN (
PUBLIC mask8259A, cascade8259, rgSysCommInt, nSysCommInt
PUBLIC fSysChannelB, fSubsysChannelA, fSubsysChannelB, pFontRamBuf
IF (FontRamBuf NE 0) THEN (
pFontRamBuf DD FontRambuf
) ELSE (
pFontRamBuf DD 0
)FI
cbitsSmdOrHdc DW 0
bSmdOrHdcMask DB 0
PUBLIC cbitsSmdOrHdc, bSmdOrHdcMask
)FI

EVEN

;****************************************************************************
; Variables for IWS StandAlone
;****************************************************************************
IF (wsType EQ iwsStandAlone ) THEN (
PUBLIC nRgMassioDisp, rgMassioDisp
PUBLIC nIOPs, IopAdrs,rgIopChan,rqDelayDisc
PUBLIC nDct

;Dummy labels
fGoingDown LABEL WORD
rqDelayDisc LABEL WORD
IopAdrs LABEL WORD
rgIopChan LABEL WORD
ackOutBuf LABEL WORD
ackInBuf LABEL WORD
dmaBuf LABEL WORD

rgsbWsUserName DB 31 DUP (0)
mask8259A DB 67h
EVEN
nDct  DW 0

IF (fMulPar NE 0) THEN (
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI
)FI
EVEN


;****************************************************************************
; Variables for IWS Cluster
;****************************************************************************
IF (wsType EQ iwsCluster ) THEN (
PUBLIC nXBlock, nSectorPerXBlock, sioClock, nDct
PUBLIC sRcb,cRcbMax
PUBLIC nIOPs, IopAdrs,rgIopChan,rqDelayDisc
PUBLIC FilterProcessExch
FilterProcessExch DW 17

; Dummy labels
fGoingDown LABEL WORD
rqDelayDisc LABEL WORD
IopAdrs LABEL WORD
rgIopChan LABEL WORD
rgsbWsUserName LABEL BYTE

IF (localFS EQ 0) THEN (
PUBLIC orgOFdc, oFdc, cFdc
orgOFdc LABEL WORD
oFdc LABEL WORD
cFdc LABEL WORD
) ELSE(
PUBLIC nRgMassioDisp, rgMassioDisp 
) FI

mask8259A DB 65h
sioClock DB sioClock
EVEN
cRcbMax  DW nRcb
sRcb  DW sRcbIws
nSectorPerXBlock DW nSectorPerXBlock
nXBlock  DW nXBlock
nDct  DW 0
saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16

lowmem SEGMENT PUBLIC 'lowmem'
; Dma buffer and ackIn and ackOut buffers must be in first 64K for IWS
; For IWS cluster, we allocate one dmaBuf for each XBlock.
dmaBuf  DW xBlockSize*nXBlock dup(0)  ;dmaBuf is a word buffer for IWS
ackInBuf  DW 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DW 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DW 16 DUP (0)				;leave room for segment boundary alignment
lowmem ENDS


IF (fMulPar NE 0) THEN (
EVEN
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI
)FI
EVEN

;****************************************************************************
; Variables for IWS MiniMaster
;****************************************************************************
IF (wsType EQ iwsMiniMaster ) THEN (
PUBLIC nRgMassioDisp, rgMassioDisp
PUBLIC nXBlock,nDct,sioClock
PUBLIC nXBlockSmall, sSmallXBlock, nSectorPerXBlock
PUBLIC nIOPs,IopAdrs,rgIopChan
PUBLIC mbIOPort,pFontRamBuf

;Dummy labels

IopAdrs LABEL WORD
rgIopChan LABEL WORD

mask8259A DB 65h
rgsbWsUserName DB EVAL(31*wsTotal+31) DUP (0)
sioClock DB sioClock
EVEN
nSectorPerXBlock DW nSectorPerXBlock
sSmallXBlock DW sMaxSmallRq
nXBlock  DW nXBlock
nXBlockSmall DW nXBlockSmall
nDct  DW wsTotal
saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16

lowmem SEGMENT PUBLIC 'lowmem'
; Dma buffer and ackIn and ackOut buffers must be in first 64K for IWS
; For IWS mini master, we have one dmaBuf in addition to XBlocks.
; XBlocks are allocated in high memory.
dmaBuf  DW xBlockSize dup(0)  ;dmaBuf is a word buffer for IWS
ackInBuf  DW 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DW 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DW 16 DUP (0)				;leave room for segment boundary alignment
lowmem ENDS

fGoingDown DB 0

IF (fMulPar NE 0) THEN (
EVEN
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI
)FI
EVEN


;****************************************************************************
; Variables for IWS IOP Master
;****************************************************************************
IF (wsType EQ iwsIopMaster ) THEN (
PUBLIC nXBuf,sXbMax,nXBufSmall,sXBMaxSmall,nDct,sioClock
PUBLIC nRgMassioDisp, rgMassioDisp 
PUBLIC iopIntLevel, sXBMax,rgDct,sioClock,rgIopChan
PUBLIC qFreeXblks,nIOPs,IopAdrs, iDct,iopBuff,fIopDump,nIopQSize
PUBLIC pFontRamBuf   
PUBLIC nXBufSmall, sXBMaxSmall, nRcb
PUBLIC qFreeXblksSmall 

;Dummy labels
ackOutBuf LABEL WORD
ackInBuf LABEL WORD
dmaBuf LABEL WORD

mask8259A DB 63h
rgIopChan DB nWsLine1,nWsLine2,nWsLine3,nWsLine4
IopAdrs  DB 40h, 41h, 50h, 51h
rgsbWsUserName DB EVAL(31*wsTotal+31) DUP (0)
sioClock DB sioClock
fIopDump DB fIopDump
EVEN
aSBuffer EQU 74+(512*nSectorPerXBlock)
sXBuf  EQU nXBlock*(aSBuffer+32)
SET (nIopQSize,nXBlock+wsTotal)
EVEN
iopIntLevel DW IopIntLevel
nIopQSize DW nIopQSize
saPerXbuf EQU (aSBuffer+15)16
saPerSmallRq EQU (sMaxSmallRq+12+15)16
qFreeXblks DB (nXBlock+2)*4+8 dup (0)
qFreeXblksSmall DB (nXBlockSmall+2)*4+8 dup (0)
iopBuff  DB 5*nIop*(nIopQSize*4+8)+4 dup (0)
EVEN
iDct  DW wsTotal dup (0)
nDct  DW wsTotal 
nIops  DW nIop
nXBuf  DW nXBlock
sXBMax  DW aSBuffer
nRcb  DW nXBlock+nXBlockSmall
nXBufSmall DW nXBlockSmall
sXBMaxSmall DW saPerSmallRq*16
rgDct  DB wsTotal*64 dup(0)
fGoingDown DB 0

IF (fMulPar NE 0) THEN (
EVEN
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI

) ELSE (
nIops  DW 0
)FI
EVEN


;****************************************************************************
; Variables for AWS210
;****************************************************************************
IF (wsType EQ aws210) THEN (
PUBLIC rgFLineDirty, rgbRuns, rgbRunsTemp
EVEN
rgFLineDirty DB 28 DUP(0)
rgbRuns DB 896 DUP(0)
rgbRunsTemp DB 36 DUP(0)
PUBLIC nXBlock, nSectorPerXBlock, sioClock, nDct
PUBLIC sRcb,cRcbMax
PUBLIC nIops,IopAdrs,rqDelayDisc
PUBLIC FilterProcessExch
FilterProcessExch DW 17

;Dummy labels
fGoingDown LABEL WORD
rqDelayDisc LABEL WORD
IopAdrs LABEL WORD
rgsbWsUserName LABEL BYTE

sioClock DB sioClock
EVEN
cRcbMax  DW nRcb
sRcb  DW sRcbAws
nSectorPerXBlock DW nSectorPerXBlock
nXBlock  DW nXBlock
nDct  DW 0
saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16

Sysgen_LowMem SEGMENT PUBLIC 'LowMem'
; Dma buffer and ackIn and ackOut buffers must be in first 3FFF bytes for AWS
; For AWS cluster, we allocate one dmaBuf for each XBlock.
; Dma is directly to and from the XBlocks.
dmaBuf  DB xBlockSize*nXBlock dup(0)  ;dmaBuf is a byte buffer for AWS
ackInBuf  DB 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DB 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DB 16 DUP (0)				;leave room for segment boundary alignment
Sysgen_LowMem ENDS

) FI
EVEN

;****************************************************************************
; Variables common to AWS220, AWS230, AWS240
;****************************************************************************
IF (wsType EQ aws220_240) THEN (
PUBLIC rgFLineDirty, rgbRuns, rgbRunsTemp
EVEN
rgFLineDirty DB 28 DUP(0)
rgbRuns DB 896 DUP(0)
rgbRunsTemp DB 36 DUP(0)
PUBLIC nRgMassioDisp, rgMassioDisp
PUBLIC mask8259A, cascade8259, rgSysCommInt, nSysCommInt
PUBLIC rgIopChan,ioBuf,rqDelayDisc,nDct
PUBLIC nIops,IopAdrs

;Dummy labels

fGoingDown LABEL WORD
rqDelayDisc LABEL WORD
IopAdrs LABEL WORD
rgIopChan LABEL WORD

Sysgen_LowMem SEGMENT PUBLIC 'LowMem'
;NOTE: iobuf should be 256 bytes, but standalone won't boot.
; It seems to work fine at 512.
; NOTE; iobuf must appear before the dma buffers, or the cluster code will not work. The reason is a mystery to me.
iobuf  DB 512 DUP (0)

IF (localFS NE 0) THEN (
; Dma buffer and ackIn and ackOut buffers must be in first 64K for AWS
; For AWS cluster, we allocate one dmaBuf for each XBlock.
; Dma is directly to and from the XBlocks.
saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16
dmaBuf  DB xBlockSize*nXBlock dup(0)  ;dmaBuf is a byte buffer for AWS
ackInBuf  DB 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DB 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DB 16 DUP (0)				;leave room for segment boundary alignment
) ELSE (
dmaBuf LABEL WORD
ackOutBuf LABEL WORD
ackInBuf LABEL WORD
) FI
Sysgen_LowMem ENDS

IF (localFS EQ 0) THEN (
PUBLIC fCommEnabled
fCommEnabled DB 0
) FI

mask8259A DB 0BDh
EVEN
nDct  DW 0

IF (localFS EQ 0) THEN (
rgsbWsUserName DB 31 DUP (0)
) ELSE (
PUBLIC nXBlock, nSectorPerXBlock
PUBLIC sioClock,sRcb,cRcbMax
sioClock DB sioClock
EVEN
cRcbMax  DW nRcb
sRcb  DW sRcbAws
nSectorPerXBlock DW nSectorPerXBlock
nXBlock  DW nXBlock
rgsbWsUserName LABEL BYTE
EVEN
PUBLIC FilterProcessExch
FilterProcessExch DW 17
)FI

) FI
EVEN

;****************************************************************************
; Variables common to AWS Master
;****************************************************************************
IF (wsType EQ awsMaster) THEN (
PUBLIC rgFLineDirty, rgbRuns, rgbRunsTemp
EVEN
rgFLineDirty DB 28 DUP(0)
rgbRuns DB 896 DUP(0)
rgbRunsTemp DB 36 DUP(0)
PUBLIC nRgMassioDisp, rgMassioDisp
PUBLIC mask8259A, cascade8259, rgSysCommInt, nSysCommInt
PUBLIC nXBlock,nDct,sioClock
PUBLIC nXBlockSmall, sSmallXBlock, nSectorPerXBlock
PUBLIC nIops,IopAdrs,rgIopChan
PUBLIC ioBuf

nSectorPerXBlock DW nSectorPerXBlock
sSmallXBlock DW sMaxSmallRq
nXBlock  DW nXBlock
nXBlockSmall DW nXBlockSmall
nDct  DW wsTotal
saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16
sXBuf  EQU nXBlock*xBlockSize
saPerSmallRq EQU (sMaxSmallRq+xBlockHeaderSize+15)16
sXBufSmall EQU saPerSmallRq * nXBlockSmall*16

Sysgen_LowMem SEGMENT PUBLIC 'LowMem'
; NOTE: iobuf must appear before the DMA buffers or the cluster code will not work. The reason for this is a mystery to me.
iobuf  DB 256 DUP (0)

; Dma buffer and ackIn and ackOut buffers must be in first 64K bytes for AWS
; For AWS master, we allocate one dmaBuf for each XBlock  big and small.
; Dma is directly to and from the XBlocks.
dmaBuf  DB (sXBuf+sXBufSmall) dup(0)  ;dmaBuf is a byte buffer for AWS
ackInBuf  DB 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DB 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DB 16 DUP (0)				;leave room for segment boundary alignment
Sysgen_LowMem ENDS

;Dummy labels

IopAdrs LABEL WORD
rgIopChan LABEL WORD

rgsbWsUserName DB EVAL(31*wsTotal+31) DUP (0)
mask8259A DB 09Dh
sioClock DB sioClock
fGoingDown DB 0
) FI
EVEN
IF (fFloppyCheck) THEN (
; The following will be used for NGen, if we like to add
; a 'Floppy Door Open Checking' feature.
; The following is the message put out by the OS when a floppy
; on which files are open is removed from the drive.

IF (fNGenHardware) THEN (

	ReinsertFloppyMsg	LABEL BYTE
		DB	80 DUP (0CEh)									;   0 to  79
		DB  '   Reinsert volume '							;  80 to  99
		DB  12 DUP (0)										; 100 to 111
		DB  ' in drive '									; 112 to 121
		DB	'0'												; 122
		DB  ' or press <ACTIONFINISH> to exit     '		; 123 to 159

	cbReinsertFloppyMsg	DB 160
	oReinsertMsgVolName	DB 100
	oReinsertMsgUnitNum	DB 122
	SaveVideoBuf DW	160 DUP (0)

)FI

IF (fIwsHardware) THEN (; IWS

	ReinsertFloppyMsg	LABEL BYTE
		DB	132 DUP (0CEh)									;
		DB  '   Reinsert volume '							;  0 to 19
		DB  12 DUP (0)										; 20 to 31
		DB  ' in drive '									; 32 to 41
		DB	'0'												; 42
		DB  ' or press <ACTIONFINISH> to exit     '		; 43 to 79
		DB  52 DUP (0)										; 80 to 131

	cbReinsertFloppyMsg	DB 264
	oReinsertMsgVolName	DB 132+20
	oReinsertMsgUnitNum	DB 132+42
	SaveVideoBuf DW	200 DUP (0)
)FI

IF (fAwsHardware) THEN (; AWS

	ReinsertFloppyMsg LABEL BYTE
		DB  84H, 65 DUP (4Eh), 15 DUP (84h, 4Eh)
		DB  80H							;  0
		DB  '   Reinsert volume '		;  1 to 20 (+20 = 20 chars)
		DB  12 DUP (0)					; 21 to 32 (+12 = 32 chars)
		DB  ' in drive '				; 33 to 42 (+10 = 42 chars)
		DB	'0'							; 43       ( +1 = 43 chars)
		DB  ' or press <ACTIONFIN'		; 44 to 65 (+22 = 65 chars)
		DB  80H,'I',  80H,'S',  80H,'H'	; 66 to 73
		DB  80H,'>',  80H,' ',  80H,'t'	; 73 to 80
		DB  80H,'o',  80H,' ',  80H,'e'	; 89 to 87
		DB  80H,'x',  80H,'i',  80H,'t'	; 95 to 
		DB  80H,' ',  80H,' ',  80H,' '	; 90 to 95
		DB	0F3H, 0F3H

	cbReinsertFloppyMsg	DB	194
	oReinsertMsgVolName DB 96+21
	oReinsertMsgUnitNum DB 96+43
	SaveVideoBuf  DB 192 DUP (0)
)FI

RemovedF0VolName	DB	13 DUP (0)
RemovedF1VolName	DB	13 DUP (0)
RemovedF0UserCount	DW	0
RemovedF1UserCount	DW	0
RemovedF0CreateDT	DD	0
RemovedF1CreateDT	DD	0
RemovedF0ModifyDT	DD	0
RemovedF1ModifyDT	DD	0
)FI

;****************************************************************************
; Variables common to all NGen
;****************************************************************************
IF ((wsType GE ngenCluster) AND NOT fMFHardware) THEN (
IF (wsType GE ngen) THEN (
PUBLIC mask8259A, cascade8259A, rgSysCommInt, nSysCommInt
mask8259A DB 07h
cascade8259A DB 0F6h
)FI

; 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

; 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

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

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

) ELSE (
cbRgCheckConfig LABEL BYTE
rgCheckConfig LABEL BYTE
cbRgCheckConfigPswd LABEL BYTE
rgCheckConfigPswd LABEL BYTE
)FI
EVEN

;****************************************************************************
; Variables common to NgenCluster
;****************************************************************************
IF (wsType EQ ngenCluster) THEN (
PUBLIC nXBlock, nSectorPerXBlock
PUBLIC sioClock,sRcb,cRcbMax
PUBLIC nIops,rqDelayDisc
PUBLIC mask8259A, cascade8259A, nDct

;Dummy labels
rgsbWsUserName LABEL BYTE
rgIopChan LABEL WORD
fGoingDown LABEL WORD
rqDelayDisc LABEL WORD

mask8259A DB 0Fh
cascade8259A DB 0F6h
sioClock DB sioClock
EVEN
nDct DW 0
PUBLIC FilterProcessExch
FilterProcessExch DW 17
nSectorPerXBlock DW nSectorPerXBlock
nXBlock  DW nXBlock
cRcbMax  DW nRcb
sRcb  DW sRcbAws

IF (fMulPar) THEN (
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI


if(not ctosp)then(
Sysgen_LowMem SEGMENT PUBLIC 'LowMem'
; XBlocks are allocated in low memory. If we allocate them dynamically in high memory we get in trouble with machines with graphics modules that allocate XBus memory.

saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16
dmaBuf  DB xBlockSize*nXBlock dup(0)  ;dmaBuf is a byte buffer 
ackInBuf  DB 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DB 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DB 16 DUP (0)				;leave room for segment boundary alignment
Sysgen_LowMem ENDS
)fi
) FI
EVEN

;****************************************************************************
; Variables for Ngen
;****************************************************************************
IF (wsType EQ ngen) THEN (
PUBLIC rgIopChan,rqDelayDisc,nIops, nDct
IF (localFS NE 0) THEN (
PUBLIC nXBlock, nSectorPerXBlock
PUBLIC sioClock,cRcbMax
PUBLIC sRcb, nIops,rqDelayDisc
if(not ctosp)then(
PUBLIC dmaBuf
)fi
)FI
IF (clusterConfig EQ standAlone) THEN (
PUBLIC fSrpUp, oRgClusterTerm
)FI

;Dummy labels

fGoingDown LABEL WORD
rqDelayDisc LABEL WORD
rgIopChan LABEL WORD
oRgClusterTerm LABEL WORD
nDct DW 0
IF (clusterConfig EQ standAlone) THEN (
fSrpUp DB 0
)FI

IF (localFS EQ 0) THEN (
rgsbWsUserName DB 31 DUP (0)
ackOutBuf LABEL WORD
ackInBuf LABEL WORD
dmaBuf LABEL WORD
) ELSE (
rgsbWsUserName LABEL BYTE
sioClock DB sioClock
EVEN
PUBLIC FilterProcessExch
FilterProcessExch DW 17
nSectorPerXBlock DW nSectorPerXBlock
nXBlock  DW nXBlock
cRcbMax  DW nRcb
sRcb  DW sRcbAws

if(not ctosp) then(
Sysgen_LowMem SEGMENT PUBLIC 'LowMem'
; XBlocks are allocated in low memory. If we allocate them dynamically in high memory we get in trouble with machines with graphics modules that allocate XBus memory.

saPerXBlock EQU (xBlockHeaderSize+xBlockRqSize+(512*nSectorPerXBlock)+15)16
xBlockSize EQU saPerXBlock*16
dmaBuf  DB xBlockSize*nXBlock dup(0)  ;dmaBuf is a byte buffer 
ackInBuf  DB 16 DUP (0)							;ackInBuf will be set to segment boundary by init
ackOutBuf  DB 16 DUP (0)							;ackOutBuf will be set to segment boundary by init
	DB 16 DUP (0)				;leave room for segment boundary alignment
Sysgen_LowMem ENDS
)fi
)FI

IF (fMulPar) THEN (
EVEN
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI
) FI

IF (clusterConfig NE cluster) THEN (
PUBLIC orgUserTable
orgUserTable DW 0
)FI


EVEN

;****************************************************************************
; Variables for Ngen Master
;****************************************************************************
IF (wsType EQ ngenMaster) THEN (
PUBLIC fGraphicsBoard, rgIopChan, nIOPs
PUBLIC nXBlock, nDct, sioClock
PUBLIC nXBlockSmall, sSmallXBlock, nSectorPerXBlock, MaxXBlocksPerUser
PUBLIC fSrpUp, oRgClusterTerm
PUBLIC MaxErrorCount
PUBLIC MaxTimeoutCount
PUBLIC TimeoutTicks
PUBLIC TeleclusterTiming

;Dummy labels

rgIopChan LABEL WORD
dmaBuf LABEL WORD						;allocated in high memory by init code
ackOutBuf LABEL WORD						;allocated in high memory by init code
ackInBuf LABEL WORD						;allocated in high memory by init code
oRgClusterTerm LABEL WORD 
fSrpUp DB 0

rgsbWsUserName DB EVAL(31*wsTotal+31) DUP (0)
sioClock DB sioClock
fGoingDown DB 0
EVEN
nDct  DW wsTotal
nSectorPerXBlock DW nSectorPerXBlock
sSmallXBlock DW sMaxSmallRq
nXBlock  DW nXBlock
nXBlockSmall DW nXBlockSmall

MaxErrorCount DB MaxErrorCount
MaxTimeoutCount DB MaxTimeoutCount
TimeoutTicks DW TimeoutTicks
TeleclusterTiming DW TeleclusterTiming
MaxXBlocksPerUser DB MaxXBlocksPerUser

IF (fMulPar) THEN (
PUBLIC rgbRunsTemp, rgbRuns, rgbRunsVirgin, rgfLineDirty
rgbRunsTemp  LABEL WORD
rgbRuns  LABEL WORD
rgbRunsVirgin  LABEL WORD
rgfLineDirty  LABEL WORD
)FI
) FI
EVEN

;********* )FI' CTOS, not FS

;****************************************************************************
; Variables for all Megaframe
;****************************************************************************
IF (fMFHardware) THEN (
PUBLIC pCdt, fSrpUp
IF (FS) THEN ('
Public rgSectMap
) ELSE (' CTOS
public ntotaluser
PUBLIC FilterProcessExch, exchFilterPocket
PUBLIC rgIopChan, oRgClusterTerm
)FI'

pCdt		DD	Cdt
oRgClusterTerm  DW	0
fSrpUp		DW	0

IF (FS) THEN ('
CdtSeg	Segment	AT 0
Cdt			Label	Byte
CdtSeg	Ends
;
;  The following is used by MassIo for Sector Scheduling
;
EVEN
rgSectMap label byte
If (fFP)  Then (
			DB	0,4,8,12,16,20,24,28
			DB	1,5,9,13,17,21,25,29
			DB	2,6,10,14,18,22,26,30
			DB	3,7,11,15,19,23,27,31
)FI
If (fDP) Then (
			DB	0,8,16,24,32,40,48,56
			DB	2,10,18,26,34,42,50,58
			DB	4,12,20,28,36,44,52,60
			DB	6,14,22,30,38,46,54,62
) FI

;
;  The following allocates the Queue used when no Iob's are available
;  when running MassIo
;
If ((fFP) OR (fDP)) Then (
Public			sIobQueue, nFreeIobQueue, rgpIobQList
sIobQueue		Dw	sMassIoRqQueue
nFreeIobQueue		Dw	sMassIoRqQueue
rgpIobQList		DD	sMassIoRqQueue Dup (0)
) FI

) ELSE (' CTOS
const	segment word public 'CONST'
rgIopChan LABEL WORD
rgbTypeTable	DB	0Ah,0Bh,0Ch,0Dh,0Eh,0Fh,40h,41h,0FFh
rgbXpChar	DB	'FTCSDRAA?'
srgbTypeTable	DW	9
const	ENDS

FilterProcessExch DW ?
exchFilterPocket DW ?

nRemoteDmaRequest	Dw	0

ibBufOutTake	DW	0
ibBufOutPut	DW	0
fBufOutOverflow	DW	0                 
rgbBufOut	DB	sKbdBuffer DUP (0)

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

bConsoleSlot	DB	1		; Slot of our console's TP
bConsolePort	DB	0		; Port on that TP
pConsoleObuf	DD	0		; Addr of output ring buffer
Even

fGoingDown      DB      0
nXBlock		EQU	THIS WORD	; make the same as nXBuf
nXBuf		DW	nXBLK 
nSectorPerXBlock DW	nSectorPerXBlock
sXBData		DW	512*nSectorPerXBlock
sSmallXBlock	DW	sMaxSmallRq
nXBlockSmall	DW	nXBlockSmall
XBlockHeaderSize DW XBlockHeaderSize+xBlockRqSize

If (fCP) Then (

fSysChannelB	DW	0FFFFh		; Realistic values later
fSysChannelC	DW	0FFFFh   
fSysChannelD	DW	0FFFFh   
fSubsysChannelA	DW	0FFFFh
fSubsysChannelB	DW	0FFFFh
fSubsysChannelC	DW	0FFFFh
fSubsysChannelD	DW	0FFFFh

rgsbWsUserName	DB	EVAL(31*wsTotal+31)	DUP	(0)
aNLcb		EQU	nLine
 
nLcb		DW	aNLcb
nDct		DW	WsTotal
		EVEN
pRgRcb		DD	?
rgNoWsLine      DB      nWsLine1,nWsLine2
rgcTimeDelay    DB      10,10 
rgfSrpClock     DB      fSrpClock1,fSrpClock2
rgcMaxRqBlk     DB      2,2
rgfLineEn       DB      0h,0h
nPTTotal		DW		0 
nT0QBlk		DW	nYBlk + nZBlk + 3
nsPtW0		dw	sPtW0Buf
nsPtW1		dw	sPtW1Buf
nsPtW2		dw	sPtW2Buf
nsPtW3		dw	sPtW3Buf
nsPtW4		dw	sPtW4Buf
nsPtW5		dw	sPtW5Buf
nsTpInBuf	dw	sTpInBuf
nsTpOutBuf	dw	sTpOutBuf
PtHdrs		equ	((XBlockHeaderSize+15)16)*16
TpInHdrs	equ	10
TpOutHdrs	equ	30
sPtHdr		dw	PtHdrs
sTpInHdr	dw	TpInHdrs
sTpOutHdr	dw	TpOutHdrs 

;
; PtHdrs (above) is the size of the T0fifostructure.
; 96 is 16 PTs * 6 windowspt
;
; We Don't know what the extra 96 (below) is for.
; We presume it is for a control byte or something.
; This structure must begin on a paragraph boundry for the linking to work
;
;t0data SEGMENT PUBLIC 'data'
;
;rgPTBuffers	db	96*PTHdrs + 96 + 16*(sPtW0Buf + sPtW1Buf + sPtW2Buf + sPtW3Buf + sPtW4Buf + sPtW5Buf) dup(0)
;t0data ends

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 (
    If (fTP) Then (
	fSysChannelB	DW	0FFFFh		; Realistic values later
	fSysChannelC	DW	0FFFFh
	fSysChannelD	DW	0FFFFh
	fSubsysChannelA	DW	0FFFFh
	fSubsysChannelB	DW	0FFFFh
	fSubsysChannelC	DW	0FFFFh
	fSubsysChannelD	DW	0FFFFh

	EVEN

	nsTpInBuf	dw	sTpInBuf
	nsTpOutBuf	dw	sTpOutBuf
	TpInHdrs	equ	10
	TpOutHdrs	equ	30
	sTpInHdr	dw	TpInHdrs
	sTpOutHdr	dw	TpOutHdrs 
	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'

	rgsbWsUserName  LABEL   BYTE
	nDct            DW      0
	cDelayDisc      LABEL   WORD 

    ) Else (
	fSysChannelA	DW	0
	fSysChannelB	DW	0   
	fSysChannelC	DW	0   
	fSysChannelD	DW	0   
	fSubsysChannelA	DW	0
	fSubsysChannelB	DW	0
	fSubsysChannelC	DW	0
	fSubsysChannelD	DW	0
	rgsbWsUserName  LABEL   BYTE
	cDelayDisc      LABEL   WORD 
	nDct            DW      0
    ) Fi
) FI
		EVEN

;  Icc 'Y' Block descriptive structures

sYblkLocal	Equ	XBlockHeaderSize+(512*nSectorPerYblk) ; header was 74

sYblk		DW	sYblkLocal
nYblk		DW	nYblk
pYblkListHead	DD	YblkArea

; Icc 'Z' Block descriptive structures

sZblkLocal	Equ	sZblk

sZblk		DW	sZblkLocal
nZblk		DW	nZblk
pZblkListHead	DD	ZblkArea
maxAdapters	dw	nAdapters
Adt		db	(10*nAdapters) dup (0)



if ((fFP) OR (fDP)) Then (

sMountTabEntry		Equ	1+13+13

maxDevMounted		Dw	nMountedDisks
nDevMounted		Dw	0
rgFpMasterMountTable	Db	(sMountTabEntry*nMountedDisks) Dup (0)

) Fi

nDummy		Equ		5			; padding of each area
			Even
pStat		DD		Stat1
Stat1		Label	Word
			DW		nWinch
			DW		nPcb
			DW		nSysExchange+nUsrExchange
nInitY		DW		nYblk
nMinY		DW		nYblk
nAvailY		DW		nYblk
nInitZ		DW		nZblk
nMinZ		DW		nZblk
nAvailZ		DW		nZblk
nInitIob	DW		nIob
nMinIOB		DW		nIob
nAvailIOB	DW		nIob
			DW		nDummy Dup (0)
sStat		DW		$Stat1

pDiskStat	DD		Stat2
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)
sDiskStat	DW		$Stat2


pProcStat	DD		Stat3
Stat3		Label	Word
nProcTick	DW		nPcb DUP (0)
		DW		nDummy Dup (0)
sProcStat	DW		$Stat3

pExchStat	DD		Stat4
Stat4		Label	Word
nExchIn		DW		(nSysExchange+nUsrExchange) DUP (0)
		DW		nDummy Dup (0)
sExchStat	DW		$Stat4

pIccStat	DD		Stat5
Stat5		Label	Word
nIccIn		DW		0
nIccOut		DW		0
nIccSkip	DW		0
nYblkCopy	DW		0
nParaIn		DW		0
nParaOut	DW		0
		DW		nDummy Dup (0)
sIccStat	DW		$Stat5

CdtSeg	Segment	Public	'Cdt'

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

ReqOffset		Equ	Offset ReqArea  Offset Cdt
RespOffset		Equ	Offset RespArea  Offset Cdt
StatOffset		Equ	Offset StatArea  Offset Cdt
If ((fFP) OR (fDP))Then (
TermOffset		Equ	Offset TermArea  Offset Cdt
LineOffset		Equ	Offset LineArea  Offset Cdt
RouteOffset		Equ	Offset RouteArea  Offset Cdt
) Else (
RouteOffset		Equ     0
)Fi

  DW	0		; slide CDT down 2 to fix AP problem with lock
Cdt			Label	Byte

'filler$0 (8)'		DB	8 Dup (?)
'bProcessorType'	DB	HardWareType
'fWatchDog'		DB	0
'ibRequestTakePtr'	DW	ReqOffset
'ibRequestPutPtr'	DW	ReqOffset
'ibRequestStartPtr'	DW	ReqOffset
'ibRequestEndPtr'	DW	ReqOffset + 5*(eval(nReqEnts1))
'ibResponseTakePtr'	DW	RespOffset
'ibResponsePutPtr'	DW	RespOffset
'ibResponseStartPtr'	DW	RespOffset
'ibResponseEndPtr'	DW	RespOffset + 5*(eval(nRespEnts1))
'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	?
'fMasterReady'	db	?
'fDisCls'		db	?
'wCpWho'		dw	?
'WCpTimer'		dw	?
'verifyCode'	db	?
'filler1'		DB	77 Dup (?)


    ; Following portion of the table is FPDP specific

If ((fFP) OR (fDP)) Then (

'nDevMounted'		DW	0
'pMasterMountTable' DD	rgFPMasterMountTable
'oTermTable'		Dw	TermOffset
'sTermTable'		Dw	sTermArea
'oLineTable'		Dw	LineOffset
'sLineTable'		Dw	sLineArea
'oRqRoute'		Dw	RouteOffset
			Dw	16 Dup (?)
'sRqRoute'		Dw	sRouteArea
			Dw	16 Dup (?)
) Fi
		Even
ReqArea		DB	nReqEnts*5 Dup (?)
		Even
RespArea	DB	nRespEnts*5 Dup (?)
		Even
StatArea	DW	sStatArea Dup (?)
		Even
If ((fFP) OR (fDP)) Then (
TermArea	Dw	sTermArea Dup (?)
LineArea	Dw	sLineArea Dup (?)
RouteArea	Db	sRouteArea Dup (?)
) Fi
	Even
CdtSeg	Ends

YSeg	Segment	Public 'Yseg'

YblkArea	Db	nYblk*sYblkLocal Dup (0)
ZblkArea	Db	nZblk*sZblkLocal Dup (0)

YSeg	Ends

;********* )FI' CTOS, not FS

) FI' Megaframe
EVEN

;****************************************************************************
; MACRO DEFINITIONS
;****************************************************************************
;
;
; EXTRN  declare a label extrn and outside of the data segment.  This will only
; work is called from within segment data.
;
*DEFINE(Extrn(label))('
data ENDS
EXTRN label:far
data SEGMENT PUBLIC 'data'
)


IF (FS) THEN (
*Define(RemoteDmaRequest(rc,newrc,pbcboffset,slotoffset))()
$EJECT
;
; macro for defining massio dispatch routines
;
*DEFINE (MassioDisp (pStartIO))(
IF (m_nRgMassioDisp EQ 0) THEN (
   rgMassioDisp label byte) FI
SET (m_nRgMassioDisp, m_nRgMassioDisp+1)
IF (NOT(ISDEF(pStartIO))) THEN(
   EXTRN(pStartIO)) FI
DD pStartIO
)
$EJECT
*DEFINE (DefineEncryptionKey (wKeyValue))()


) ELSE (' CTOS, not FS
*DEFINE (MassioDisp (pStartIO))()
$EJECT
;
; macro for defining Remote Dma requests
; which need to be massaged by ICC
;
*Define(RemoteDmaRequest(rc,newrc,pbcboffset,slotoffset))(
If (m_nRemoteDmaRequests EQ 0) Then (
		Even
rgRemoteDmaRequest	Label	Byte
) Fi
DW	Rc, NewRc
DB	pbcboffset, slotoffset
Set(m_nRemoteDmaRequests,m_nRemoteDmaRequests+1)
)
$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.
; Org back and define the temporary encryption key buffer.
PUBLIC EncryptionKey, TEK
_sbCb_			db ?
EncryptionKey	dw wKeyValue
TEK label byte
_cbKey_ EQU OFFSET TEK  OFFSET EncryptionKey
ORG OFFSET _sbCb_
				DB _cbKey_
ORG OFFSET TEK
				db _cbKey_ DUP(?)
)
$EJECT
;
; macro for 8259 cascade flags
;
*DEFINE (InterruptCascadeLevel(n))(
IF ((n NE 0) AND (n NE 2) AND (n NE 5) AND (n NE 6)) THEN (Error(Illegal cascade level: n))
ELSE (SET(cascade8259,cascade8259 OR (1 SHL n)))FI
)
$EJECT
;
; macro for defining real mode raw interupt handler structure
;
*DEFINE (RawInterrupt (level,entry))(
IF (m_nRawInt EQ 0) THEN (
rgRawIntDesc	LABEL	WORD
) FI
IF (not(*Isdef(entry))) THEN (
EXTRN(entry)
) FI
DB level
DD entry
SET(m_nRawInt, m_nRawInt+1)
)
$EJECT
;
; Macro for defining real mode mediated interupt handler structure.  The macro has a side effect of computing the max type number
; for use later in calculating the size of the mediated interrupt table.
;
*DEFINE (MediatedInterrupt (type,f8259,entry))(
IF (m_nMediatedInt EQ 0) THEN (
rgMediatedIntDesc	LABEL	WORD
) FI
EXTRN(entry)
DB type,f8259
DD entry
SET(m_nMediatedInt, m_nMediatedInt+1)
IF (m_typeMax LT type) THEN (Set(m_typeMax,type)) FI
)
$EJECT
;
; macro for defining protected mode software interupt handler structure
;
*DEFINE (SoftwareInterrupt (level,entry,sStack,fMediated))(
IF (m_nSoftwareInt EQ 0) THEN (
rgSoftwareIntDesc	LABEL	WORD
) FI
IF (not(*Isdef(entry))) THEN (
EXTRN(entry)
) FI
DB level
DD entry
DW sStack
DB fMediated
SET(m_nSoftwareInt, m_nSoftwareInt+1)
)
$EJECT
;
; Macro for defining protected mode hardware interupt handler structure.
;
*DEFINE (HardwareInterrupt (type,entry,sStack,fMediated))(
IF (m_nHardwareInt EQ 0) THEN (
rgHardwareIntDesc	LABEL	WORD
) FI
EXTRN(entry)
DB type 
DD entry
DW sStack
DB fMediated
SET(m_nHardwareInt, m_nHardwareInt+1)
IF (m_typeMax LT type) THEN (Set(m_typeMax,type)) FI
)
)FI' CTOS, not FS

IF (FS) THEN (


*DEFINE(ResidentDataBoundry(size))(
OsTable		SEGMENT PUBLIC 'Data'
DGroup GROUP OsTable
rgOsTable	DB size DUP(0)
EVEN
endOsTable	DW 0
OsTable		ENDS
)

*DEFINE (InterruptCascadeLevel(n))()
*DEFINE (MediatedInterrupt (type,f8259,entry))()
*DEFINE (RawInterrupt (level,entry))()

*DEFINE (MapExchange(veIndex, name, exch))()
*DEFINE (SymExchange(name, exch))()
*DEFINE (AssignSysExch(exch))()
*DEFINE (SysExch)()
*DEFINE (AllocSysExch(name))()
*DEFINE (RequestFileName(name))()

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

sMediatedIntTable EQU maxMedInterruptType+1
sIntSwtbl	DW sMediatedIntTable
IntSwTbl	DW cwIntSwTblEntry*sMediatedIntTable DUP (0)
rgOsTable	DB size DUP(0)
EVEN
endOsTable	DW 0
)

$EJECT
;
; define Exchange map
;
*DEFINE (MapExchange(veIndex, name, exch))('
IF (m_nVirtualExch EQ 0) THEN(rgExchReal label byte
)FI
SET (m_nVirtualExch, m_nVirtualExch + 1)
IF (eval(0veIndex) NE m_nVirtualExch) THEN('
Error(Virtual Exchange out of sequence: veIndex))
ELSE('
'
MATCH(exch2 m_RHS)(exch)' Take leading space off exch, put in exch2
WHILE(LEN(exch2) EQ 0)(MATCH(exch2 m_RHS)(m_RHS))' Maybe >1 space
'
IF (LES(substr(exch2,1,1),9) AND GES(exch2,0))THEN('constant
m_valname EQU exch2
IF (fMFHardware) THEN (
 DW exch2
) ELSE (
 DB exch2
)FI
)ELSE('previously defined EQU symbol
m_valname EQU m_valexch2
IF (fMFHardware) THEN (
 DW m_valexch2
) ELSE (
 DB m_valexch2
)FI
)FI
)FI
)
*DEFINE (SymExchange(name, exch))('
MATCH(exch2 m_RHS)(exch)' Take leading space off exch, put in exch2
WHILE(LEN(exch2) EQ 0)(MATCH(exch2 m_RHS)(m_RHS))' Maybe >1 space
'
IF (LES(substr(exch2,1,1),9) AND GES(exch2,0))THEN('constant
m_valname EQU exch2
)ELSE('previously defined EQU symbol
m_valname EQU m_valexch2
)FI
)
$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))('
IF (TestSysExch(exch)) THEN (Error(Duplicate Sys Exch Defexch)'
)ELSE(MakeSysExch(exch)'
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
)
$EJECT
;
; define RequestFileNames
;
*DEFINE (RequestFileName(name))('
IF (m_nRequestFileNames EQ 0) THEN(rgRequestFileNames label byte
)FI'
SET (m_nRequestFileNames, m_nRequestFileNames + 1)'
	DB	Len(name)
	DB	'name'
)
)FI' CTOS

$EJECT
;
; define the CTOS processes
;
*DEFINE (OsProcDesc(pEntry, sStack, priority, defaultExch))('
IF (m_nOsProcDesc EQ 0) THEN(rgOsProcDesc label byte
)FI'
SET (m_nOsProcDesc, m_nOsProcDesc + 1)'
EXTRN(pEntry)'
DD	pEntry
DW	sStack
DB	priority
DW	IF(defaultExch EQ 0) THEN(0)ELSE(SysExch)FI
)
$EJECT
;
; procedures to do initially on startup
;
*DEFINE(InitProcHardware(pEntry))('
IF (m_nInitProcHardware EQ 0) THEN ('
rgInitProcHardware label byte
)FI'
SET (m_nInitProcHardware, m_nInitProcHardware+1)'
EXTRN(pEntry)'
DD pEntry
)
$EJECT
;
; procedures to do before turning on interupts
;
*DEFINE(InitProcIntDisable(pEntry))('
IF (m_nInitProcIntDisable EQ 0) THEN ('
rgInitProcIntDisable label byte
)FI'
SET (m_nInitProcIntDisable, m_nInitProcIntDisable+1)'
EXTRN(pEntry)'
DD pEntry
)
$EJECT
;
; procedures to do after turning on interupts
;
*DEFINE(InitProcIntEnable(pEntry))('
IF (m_nInitProcIntEnable EQ 0) THEN ('
rgInitProcIntEnable label byte
)FI'
SET (m_nInitProcIntEnable, m_nInitProcIntEnable+1)'
EXTRN(pEntry)'
DD pEntry
)
$EJECT
;
; requests to initialize RTC
;
*DEFINE (RtcRq(pRequestBlock,timeInterval,resetValue,cEvents,exchange,rqCode))(
IF (m_nRgInitRtcRequest EQ 0) THEN(rgInitRtcRequest label byte)FI
SET (m_nRgInitRtcRequest, m_nRgInitRtcRequest+1)
EXTRN(pRequestBlock)
DD	pRequestBlock
DW	timeInterval,resetValue,cEvents,exchange,rqCode
)


*DEFINE (RequestNoRemoteTermination(rc)) (
IF (clusterConfig EQ cluster) THEN (
IF (nRqNoRemoteTerm EQ 0) THEN (
rgRqNoRemoteTermination LABEL BYTE
)FI
DW rc
SET(nRqNoRemoteTerm, nRqNoRemoteTerm+1)
)FI
)
*DEFINE (EndRemoteTermination) (
IF (clusterConfig EQ cluster) THEN (
PUBLIC prgRqNoRemoteTermination, nRqNoRemoteTermination
prgRqNoRemoteTermination DD rgRqNoRemoteTermination
nRqNoRemoteTermination DW nRqNoRemoteTerm
)FI
)


IF (NOT FS) THEN (' CTOS'
$EJECT
;
; Macro to reserve a communication channel for system use
;
*DEFINE (SysCommInt(iLine,pTxIsr,pExtIsr,pRxIsr,pSpRxIsr))(
IF (m_nSysCommInt EQ 0) THEN(rgSysCommInt label byte)FI
SET (m_nSysCommInt, m_nSysCommInt+1)
IF (pTxIsr NE 0) THEN (EXTRN(pTxIsr))FI
IF (pExtIsr NE 0) THEN (EXTRN(pExtIsr))FI
IF (pRxIsr NE 0) THEN (EXTRN(pRxIsr))FI
IF (pSpRxIsr NE 0) THEN (EXTRN(pSpRxIsr))FI
DW	iLine
DD	pTxIsr,pExtIsr,pRxIsr,pSpRxIsr
)

' Dummy macros for CTOS nonFS
*DEFINE (Floppy(name , password ))()
*DEFINE (HDisk(name , password ))()
*DEFINE (DcbDisk(unitNum,retryCnt,fHardDisk, name , password ))()
*DEFINE (SCSIdevice(name , password ))()

) ELSE (' FS'
$EJECT
;
; The next set of macros define device control blocks.  The entry macros are:
;    DcbDisk
;    DcbLptr
;
; These macros call internal macros:
;    SetName
;    SetDcb
;    DcbHardDisk
;    DcbFloppy
;
*DEFINE(SetName)(
Set(m_sName,Len(m_Name))
Set(m_sPass,Len(m_Pass))
IF ((m_sName EQ 0) OR (m_sName GT 12)) THEN (Error(Illegal device name:m_name))FI
IF (m_sPass GT 12) THEN (Error(Illegal device password:m_pass))FI

'sbDevName(13)
    DB m_sName
    IF (m_sName NE 0) THEN (DB 'm_Name')FI
    IF (m_sName NE 12) THEN (DB EVAL(12m_sName) DUP (' '))FI
'sbDevPassWord(13)
    DB m_sPass
    IF (m_sPass NE 0) THEN (DB 'm_Pass')FI
    IF (m_sPass NE 12) THEN (DB EVAL(12m_sPass) DUP (' '))FI
)
$EJECT
*DEFINE(SetDcb)(
SET(nDcb, nDcb+1)
IF(nDcb EQ 1) THEN(DEFINE(dcb)(0))FI
IF(nDcb EQ 2) THEN(DEFINE(dcb)(1))FI
IF(nDcb EQ 3) THEN(DEFINE(dcb)(2))FI
IF(nDcb EQ 4) THEN(DEFINE(dcb)(3))FI
IF(nDcb EQ 5) THEN(DEFINE(dcb)(4))FI
IF(nDcb EQ 6) THEN(DEFINE(dcb)(5))FI
IF(fMFHardware) THEN(
IF(nDcb GE 7) THEN(Error(too many DCBs:nDcb))FI
)ELSE(
IF(nDcb EQ 7) THEN(DEFINE(dcb)(6))FI
IF(nDcb EQ 8) THEN(DEFINE(dcb)(7))FI
IF(nDcb EQ 9) THEN(DEFINE(dcb)(8))FI
IF(nDcb EQ 10) THEN(DEFINE(dcb)(9))FI
IF(nDcb EQ 11) THEN(DEFINE(dcb)(10))FI
IF(nDcb EQ 12) THEN(DEFINE(dcb)(11))FI
IF(nDcb EQ 13) THEN(DEFINE(dcb)(12))FI
IF(nDcb EQ 14) THEN(DEFINE(dcb)(13))FI
IF(nDcb EQ 15) THEN(DEFINE(dcb)(14))FI
IF(nDcb EQ 16) THEN(DEFINE(dcb)(15))FI
IF(nDcb EQ 17) THEN(DEFINE(dcb)(16))FI
IF(nDcb EQ 18) THEN(DEFINE(dcb)(17))FI
IF(nDcb EQ 19) THEN(DEFINE(dcb)(18))FI
IF(nDcb EQ 20) THEN(DEFINE(dcb)(19))FI
IF(nDcb EQ 21) THEN(DEFINE(dcb)(20))FI
IF(nDcb EQ 22) THEN(DEFINE(dcb)(21))FI
IF(nDcb EQ 23) THEN(DEFINE(dcb)(22))FI
IF(nDcb GE 24) THEN(Error(too many DCBs:nDcb))FI
)FI
DEFINE(dcbdcb)(dcbdcb)
)
$EJECT

idleState	EQU	0
readyStatus	EQU	0
remountedStatus	EQU	2

IF(fMFHardware) THEN (
*DEFINE (DcbDisk(unitNum,retryCnt,fHardDisk, name , password ))(
SetDcb
DEFINE(m_Name)(name)
DEFINE(m_Pass)(password)
DcbHDisk (dcb,unitNum,0,retryCnt))

*DEFINE (DcbHDisk(dcb, unitNum, f8inch, retryCnt))(
dcbdcb LABEL BYTE
'fMountable		'DB	0FFh
'fNonSharable		'DB	0
'fRemovable		'DB	0
If (fFP) Then (
'fNoMultiTrack		'DB	0FFh '  ; WD1010 cannot cross tracks'
) Else (
If (fDP) Then (
'fNoMultiTrack		'DB	0    '  ; SMD can cross tracks'
) Fi
) Fi
'fAttention		'DB	0
'fTimeout		'DB	0
SetName
'controllerNum		'DB	0
'unitNum		'DB	unitNum
'state			'DB	idleState
'unitStatus		'DB	remountedStatus
If (fFP) Then (
'deviceClass		'DB	0
) Else (
If (fDP) Then (
'deviceClass		'DB	01
) Fi
) Fi
'userCount		'DB	0
'oVhb			'DW	0
'oIobFirst		'DW	0
'oIobActive		'DW	0
' lfaMax(2)		'DW	0h
'                      'DW	080h
'lfaMask		'DW	511
'verifyKey		'DW	unitNum + 1
'ovlyprocOpen		'DW	0
'ovlyprocClose		'DW	0
'setRetryCnt		'DW	retryCnt
'softErrorCnt		'DW	0
'hardErrorCnt		'DW	0
'currentCylinder	'DW	0F000h
If (fFP) Then (
'sectorSizeCode	'DB	1  '  ; refers to WD1010 code '
'gapLength		'DB	18h
'writePrecompCyl	'DB	020h
'stepRate		'DB	08h
'bytesPerSector	'DW	512
'sectorsPerTrack	'DW	16
'tracksPerCylinder	'DW	6
'cylindersPerDisk	'DW	256
'trackSeekTime		'DB	020h
'settleTime		'DB	010h
'fOnline		'DB	0
) Else (
If (fDP) Then (
'sectorSizeCode	'DB	2  '  ; refers to IWS size convention '
'gapLength		'DB	00h
'writePrecompCyl	'DB	000h
'stepRate		'DB	00h
'bytesPerSector	'DW	512
'sectorsPerTrack	'DW	32
'tracksPerCylinder	'DW	7
'cylindersPerDisk	'DW	589
'trackSeekTime		'DB	00h
'settleTime		'DB	00h
'fOnline		'DB	0
) Fi
) Fi
)

)ELSE(' Workstation

*DEFINE (Floppy(name , password ))(
SetDcb
DEFINE(m_Name)(name)
DEFINE(m_Pass)(password)
IF (WsType LE 3) THEN (' IWS workstations
   DcbFloppy(dcb,FloppyUnitnum,4)
   Set(FloppyUnitNum, FloppyUnitNum+1))
ELSE (' Aws or NGEN workstation
   IF ((HardwareType EQ 2) OR (HardwareType EQ 4)) THEN (' AWS 220,230 or NGEN
      DcbFloppy(dcb,FloppyUnitNum,4)
      Set(FloppyUnitNum, FloppyUnitNum+1))
   ELSE (' Aws 240
      DcbHDisk(dcb,HDiskUnitNum,0,4,0)
      Set(HDiskUnitNum, HDiskUnitNum+1))
   FI)
FI)
   
*DEFINE (HDisk(name , password ))(
SetDcb
DEFINE(m_Name)(name)
DEFINE(m_Pass)(password)
IF (WsType LE 3) THEN (' IWS workstations
   DcbHDisk(dcb,HDiskUnitNum,1,4,0))
ELSE (' Aws or NGen workstation
   DcbHDisk(dcb,HDiskUnitNum,0,4,0))
FI
Set(HDiskUnitNum, HDiskUnitNum+1)
)

*DEFINE (SCSIdevice(name , password ))(
SetDcb
DEFINE(m_Name)(name)
DEFINE(m_Pass)(password)
IF (WsType GE ngen) THEN (' NGen workstations
   DcbHDisk(dcb,SCSIUnitNum,0,4,1))
ELSE (' Aws, Iws or NGen cluster workstation
   Error(no SCSI allowed on AWS, IWS or NGen cluster workstation.))
FI
Set(SCSIUnitNum, SCSIUnitNum+1)
)

*DEFINE (CTape(name , password ))(
SetDcb
DEFINE(m_Name)(name)
DEFINE(m_Pass)(password)
IF (WsType LE 3) THEN (' IWS workstations
   DcbHDisk(dcb,HDiskUnitNum,2,0,0))
ELSE (' Aws or NGen workstation
   Error(no CTape allowed on AWS or NGen))
FI
Set(HDiskUnitNum, HDiskUnitNum+1)
)

$EJECT
*DEFINE (DcbHDisk(dcb, unitNum, f8inch, retryCnt, fSCSI))(
dcbSeg SEGMENT PUBLIC 'COED'
dcbdcb LABEL BYTE
IF((HardwareType EQ 3) AND (unitNum EQ 0)) THEN ( ' AWS240 floppy
'fMountable		'DB	0FFh
'fNonSharable		'DB	0
'fDoubleDensity	'DB	0FFh
'fNoMultiTrack		'DB	0
'fAttention		'DB	0
'fTimeout		'DB	0
SetName
'controllerNum		'DB	0
'unitNum		'DB	unitNum
'state			'DB	idleState
'unitStatus		'DB	remountedStatus
'deviceClass		'DB	0
'userCount		'DB	0
'oVhb			'DW	0
'oIobFirst		'DW	0
'oIobActive		'DW	0
' lfaMax(2)		'DW	0C000h
'                      'DW	00004h
'lfaMask		'DW	511
'verifyKey		'DW	unitNum + 1
'ovlyprocOpen		'DW	0
'ovlyprocClose		'DW	0
'setRetryCnt		'DW	retryCnt
'softErrorCnt		'DW	0
'hardErrorCnt		'DW	0
'currentCylinder	'DW	0FFFFh
'sectorSizeCode	'DB	1
'gap length (2)	'DB	004h
'			'DB	036h
'datalength		'DB	0FFh
'bytesPerSector	'DW	200h
'sectorsPerTrack	'DW	8h
'tracksPerCylinder	'DW	1h
'cylindersPerDisk	'DW	4Ch
'not used         	'DB	0
'reserved         	'DB	0
'reserved         	'DB	0
'reserved         	'DB	0

) ELSE ( ' IWS hard disk or AWS240  NGen hard disk or IWS CTape or 
'fMountable		'DB	0FFh
'fNonSharable		'DB	0
'fDoubleDensity	'DB	0
'fNoMultiTrack		'DB	0
'fAttention		'DB	0
'fTimeout		'DB	0
SetName
'controllerNum		'DB	0
'unitNum		'DB	unitNum
'state			'DB	idleState
'unitStatus		'DB	remountedStatus
'deviceClass		'DB IF (fSCSI) THEN (6) ELSE (0) FI
'userCount		'DB	0
'oVhb			'DW	0
'oIobFirst		'DW	0
'oIobActive		'DW	0
IF (f8inch NE 2) THEN ('5 inch or 8 inch, not Cartridge Tape.
' lfaMax(2)		'DW	IF (f8inch) THEN (0h) ELSE (06000h) FI
'                      'DW	IF (f8inch) THEN (080h) ELSE (0bdh) FI
'lfaMask		'DW	511
'verifyKey		'DW	unitNum + 1
'ovlyprocOpen		'DW	0
'ovlyprocClose		'DW	0
'setRetryCnt		'DW	retryCnt
'softErrorCnt		'DW	0
'hardErrorCnt		'DW	0
'currentCylinder	'DW	0FFFFh
IF ((wsType EQ aws220_240) OR (wsType EQ awsMaster)) THEN (
'sectorSizeCode	'DB	1
) FI
IF ((wsType NE 5) AND (wsType NE 6)) THEN (
'formatOffset		'DB	0
) FI
'formatSapce		'DB	1
'not used		'DB	0
'not used		'DB	0
'bytesPerSector	'DW	512
'sectorsPerTrack	'DW	IF (f8inch) THEN (16) ELSE (30) FI
'tracksPerCylinder	'DW	4
'cylindersPerDisk	'DW	IF (f8inch) THEN (256) ELSE (202) FI
'fInhibitECC      	'DB	0
'timeInterval     	'DB	0
'resetValue       	'DW	0
'cEvents          	'DW	0
'respExch         	'DW	0

'oDcb             	'DW	0 
'rqCode           	'DW	0 
'fLockRequest     	'DB	0 
'fStartSeek       	'DB	0 
'bAttentionStatus 	'DB	0 

'pbData           	'DD	0 
'cbData           	'DW	0 
'dataIndex        	'DW	0 

'fDoDma           	'DB	0 
'fDisconnected    	'DB	0 
'SCSIphase        	'DB	0 
'SCSIStatus       	'DB	0 
'mainStatus       	'DW	0 
'SCSIerc          	'DW	0 
'SCSIState        	'DW	0 
'rgbSCSICmd       	'DB	 10 DUP(0)
'CmdIndex         	'DW	0 
'rgbSCSICmdSave   	'DB	 10 DUP(0)
'residualwordCount	'DW	0 
'DMAaddress       	'DW	 2  DUP(0)
'DMAIndex         	'DW	0 
'rgbSCSISenseByts 	'DB	 32 DUP(0)

) ELSE ('Cartridge Tape.
' lfaMax(2)		'DW	0FE00h
'                      'DW	08Fh
'lfaMask		'DW	511
'verifyKey		'DW	unitNum + 1
'ovlyprocOpen		'DW	0
'ovlyprocClose		'DW	0
'setRetryCnt		'DW	retryCnt
'softErrorCnt		'DW	0
'hardErrorCnt		'DW	0
'currentCylinder	'DW	0FFFFh
'not used		'DB	0
'not used		'DB	0
'not used		'DB	0
'not used		'DB	0
'bytesPerSector	'DW	512
'sectorsPerTrack	'DW	9
'tracksPerCylinder	'DW	1
'cylindersPerDisk	'DW	2048
'fInhibitECC      	'DB	0FFh
'reserved         	'DB	0
'reserved         	'DB	0
'reserved         	'DB	0
)FI
dcbSeg ends
)FI
)
$EJECT
;**********************************************
;   Macro which defines DCB for the floppy    *
;**********************************************

*DEFINE (DcbFloppy(dcb, unitNum, retryCnt))(
dcbSeg SEGMENT PUBLIC 'COED'
dcbdcb LABEL BYTE
'fMountable		'DB	0FFh
'fNonSharable		'DB	0
'fDoubleDensity	'DB	0FFh
'fNoMultiTrack		'DB	0FFh
'fAttention		'DB	0
'fTimeout		'DB	0
Setname
'controllerNum		'DB	0
'unitNum		'DB	unitNum
'state			'DB	idleState
'nitStatus		'DB	remountedStatus
'deviceClass		'DB	1
'userCount             'DB	0
'oVhb                  'DW	0
'oIobFirst             'DW	0
'oIobActive            'DW	0
IF (wsType LT 4) THEN (
'lfaMax(2)		'DW	600h,9
) FI
IF ((wsType EQ aws220_240)  OR (wsType GE ngen)) THEN (
'lfaMax(2)		'DW	0D000h,4
) FI
'lfaMask		'DW	511
'verifyKey		'DW	EVAL(unitNum+1)
'ovlyprocOpen		'DW	0
'ovlyprocClose		'DW	0
'setRetryCnt		'DW	retryCnt
'softErrorCnt		'DW	0
'hardErrorCnt		'DW	0
'currentCylinder	'DW	0FFFFh
IF (wsType LT 4) THEN (
'sectorSizeCode	'DB	02
'gapLength(2)		'DB	1Bh, 54h
'dataLength		'DB	0FFh
'bytesPerSector	'DW	512
'sectorsPerTrack	'DW	15
'tracksPerCylinder	'DW	1
'cylindersPerDisk	'DW	77
) FI
IF ((wsType EQ aws220_240) OR (wsType GE ngen)) THEN (
'sectorSizeCode	'DB	01
'gapLength(2)		'DB	04h, 36h
'dataLength		'DB	0FFh
'bytesPerSector	'DW	512
'sectorsPerTrack	'DW	8
'tracksPerCylinder	'DW	1
'cylindersPerDisk	'DW	77
) FI
'fInhibitECC      	'DB	0
'reserved         	'DB	0
'reserved         	'DB	0
'reserved         	'DB	0
dcbSeg ends
)
)FI' Workstation


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


' Dummy macros for FS

*Define(ExitRunFile(name , password, priority))()
*Define(CnfgInitFile(name))()
*Define(ConfigurationFile(name , password, priority))()
*Define(WsConfigurationFile(name))()
*Define(InitFileSpec(name , password, priority))()
*Define(NlsFileSpec(name , password))()
*Define(InstallVdmSpec(name , password))()
*Define(InstallKbdSpec(name , password))()
*Define(InstallMathSpec(name , password))()
*Define(ExtCrashDumpSpec(name , password))()
*Define(OEM1Spec(name , password))()
*Define(OEM2Spec(name , password))()
*Define(OEM3Spec(name , password))()
*Define(OEM4Spec(name , password))()
*Define(SwapFileTryFirst(name,pswd))()
*Define(SwapFileTryEach(name,pswd,ib,size))()
*Define(DefineXbusModule(id,cK,fRmos,fMode3))()

)FI' FS


IF (NOT FS) THEN (' CTOS'

$EJECT
*Define(ExitRunFile(name , password, priority))(
sbExitRunFileSpec DB LEN(Name),'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbExitRunFilePswd DB LEN(Password),'Password'
                  DB EVAL(12LEN(password)) DUP (0)
exitRunFilePrio   DB priority
exitRunFilePrioSave DB priority

IF(fVarPar)THEN(
PUBLIC sbExitRunFileDefault, sbExitRunFileDefPswd, ExitRunFileDefPrio
sbExitRunFileDefault DB 79 DUP (0)
sbExitRunFileDefPswd DB 13 DUP (0)
ExitRunFileDefPrio DB ?
)FI
EVEN
)
$EJECT

*Define(CnfgInitFile(name))(
		  Even
Ifn		  DB  'name'
		  DB  Eval(40Len(name)) Dup (0)
pbInitFileName	  DD  Ifn
cbInitFileName    DW  LEN(Name)
)

$EJECT
*Define(ConfigurationFile(name , password, priority))(
sbConfigFileSpec DB LEN(Name),'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbConfigFilePswd DB LEN(Password),'Password'
                  DB EVAL(12LEN(password)) DUP (0)
configFilePrio   DB priority
EVEN
)
*Define(WsConfigurationFile(name))(
sbWsConfigFileSpec DB LEN(Name),'Name'
EVEN
)
$EJECT
*Define(InitFileSpec(name , password, priority))(
sbInitFileSpec DB LEN(Name),'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbInitFilePassword DB LEN(Password),'Password'
                  DB EVAL(12LEN(password)) DUP (0)
initFilePrio   DB priority
EVEN
)

$EJECT
*Define(NlsFileSpec(name , password))(
sbNlsFileSpec DB LEN(Name),'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbNlsFilePassword DB LEN(Password),'Password'
                  DB EVAL(12LEN(password)) DUP (0)
EVEN
)
$EJECT
*Define(InstallVdmSpec(name , password))(
sbInstallVdmSpec DB LEN(Name),'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbInstallVdmPswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(InstallKbdSpec(name , password))(
sbInstallKbdSpec DB LEN(Name),'Name'
sbInstallKbdPswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(InstallMathSpec(name , password))(
sbInstallMathSpec DB LEN(Name),'Name'
sbInstallMathPswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(ExtCrashDumpSpec(name , password))(
sbExtCrashDumpSpec DB LEN(Name),'Name'
sbExtCrashDumpPswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(OEM1Spec(name , password))(
sbOEM1Spec DB LEN(Name),'Name'
sbOEM1Pswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(OEM2Spec(name , password))(
sbOEM2Spec DB LEN(Name),'Name'
sbOEM2Pswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(OEM3Spec(name , password))(
sbOEM3Spec DB LEN(Name),'Name'
sbOEM3Pswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(OEM4Spec(name , password))(
sbOEM4Spec DB LEN(Name),'Name'
sbOEM4Pswd DB LEN(Password),'Password'
EVEN
)
$EJECT
*Define(ScratchVolumeSpec(name))(
sbScratchVolumeSpec DB LEN(Name), 'Name'
                    DB EVAL(12LEN(Name)) DUP (0)
EVEN
)
$EJECT
*Define(SwapFileTryFirst(name,pswd))(
sbSwapFileTryFirst DB LEN(Name), 'Name'
                  DB EVAL(92LEN(Name)) DUP (0)
sbSwapFileTryFirstPswd DB LEN(Pswd), 'Pswd'
EVEN
)
*Define(SwapFileTryEach(name,pswd,ib,size))(
sbSwapFileTryEach DB LEN(Name), 'Name'
sbSwapFileTryEachPswd DB LEN(Pswd), 'Pswd'
EVEN
ibSwapFileNumber DW ib
swapFileSize DW eval(size*1024),eval(size64)
)
$EJECT
*Define(DefineXbusModule(id,cK,fRMOS,fMode3Master))(
IF (m_iModDescMax EQ 0) THEN (
rgModDesc	LABEL	WORD
) FI
DB id
DW cK
DB fRMOS
DB fMode3Master
SET(m_iModDescMax, m_iModDescMax+1)
)

)FI' CTOS


;
; final  set counters in various tables, create gen table.
;
IF(fMFHardware) THEN (
*DEFINE (Final)(

IF (FS) THEN (
If ((fFP) OR (fDP))  Then (
    RtcRq(rqTimeMassIo,50,50,0,8,0FFFFh)'		; watchdog timer'
) FI

If (fFP) then (
    RtcRq(rqTimePollMassIo,20,20,0,8,0FFFEh)'		; polling timer'
) FI

) ELSE (' CTOS
IF (m_nVirtualExch EQ 0 ) Then (Error (No Virtual Exch) )FI
)FI

m_temp label byte

org offset nOsProcDesc
DW	m_nOsProcDesc
IF (NOT FS) THEN (' CTOS
org offset nRemoteDmaRequest
DW	m_nRemoteDmaRequests
if(ctosp)then(
org offset nSoftwareInt
DW	m_nSoftwareInt
org offset nHardwareInt
DW	m_nHardwareInt
)else(
org offset nRawInt
DW	m_nRawInt
org offset nMediatedInt
DW	m_nMediatedInt              
)fi

org offset nExchg
DW	m_SysExch+1 + nUsrExchange
org offset userExchFirst
DW	m_SysExch+1
)FI' CTOS

org offset m_temp

EVEN
nRgInitRtcRequest	DW	m_nRgInitRtcRequest
nInitProcHardware	DW	m_nInitProcHardware
nInitProcIntDisable	DW	m_nInitProcIntDisable
nInitProcIntEnable	DW	m_nInitProcIntEnable
IF (FS) THEN ('
nRgMassioDisp		DW	m_nRgMassioDisp
initSysDevNum		DW	IF (*IsDef(SysDevNum)) THEN (SysDevNum) ELSE (0FFFFh)FI
) ELSE (' CTOS
nSysCommInt		DW	m_nSysCommInt

; MFCTOS 3.00 
nRequestFileNames	DB	m_nRequestFileNames
srgExchReal		DB	m_nVirtualExch
fCheckMem		DB	fCheckMem
fCheckECC	 	DB 	fCheckEcc
		
IF (nUcb NE nPartitions) THEN (Error(nUCB Not Equal to nPartitions)) FI
IF (m_nRequestFileNames EQ 0) THEN (rgRequestFileNames Label Byte) FI
if(ctosp)then(
IF (m_nSoftwareInt EQ 0)        THEN (rgSoftwareIntDesc	label	byte) FI
IF (m_nHardwareInt EQ 0)        THEN (rgHardwareIntDesc    label byte) FI
)else(
IF (m_nRawInt EQ 0)             THEN (rgRawIntDesc	label	byte) FI
IF (m_nMediatedInt EQ 0)        THEN (rgMediatedIntDesc    label byte) FI
)fi
If (m_nRemoteDmaRequests EQ 0) Then (rgRemoteDmaRequest Label Byte) Fi
)FI' CTOS
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_nRgMassioDisp EQ 0) THEN (rgMassioDisp label byte) FI
IF (m_nSysCommInt EQ 0) THEN (rgSysCommInt label byte) FI
If (m_nRgInitRtcRequest EQ 0) Then (rgInitRtcRequest Label Byte) FI

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

)ELSE(' Workstation final

*DEFINE (Final)(

IF (NOT FS) THEN (
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
)FI' NOT FS

IF (FS) THEN (
IF ((wsType EQ iwsStandAlone) OR (wsType EQ iwsMiniMaster)
 OR (wsType EQ iwsIopMaster) ) THEN ( ;
RtcRq(rqTimeMassIo,50,50,0,8,0FFFFh)'		; watchdog timer'
) FI

IF ((wsType EQ ngen) OR (wsType EQ ngenMaster) ) THEN ( ;
RtcRq(rqTimeMassIo,170,170,0,8,0FFFFh)'		; watchdog timer'
) FI

IF ((wsType EQ awsMaster) OR (wsType EQ aws220_240)) THEN ('
IF ((hardwareType EQ 3) OR (wsType EQ awsMaster)
) THEN (' hard disk
RtcRq(rqTimeMassIo,65,65,0,8,0FFFFh)'		; watchdog timer'
)ELSE('floppies
RtcRq(rqTimeMassIo,50,50,0,8,0FFFFh)'		; watchdog timer'
) FI ) FI

IF ((wsType EQ iwsCluster) AND (localFS NE 0)) THEN (
RtcRq(rqTimeMassIo,50,50,0,8,0FFFFh)'		; watchdog timer'
) FI

IF ((wsType EQ ngen) OR (wsType EQ ngenMaster)) THEN (
RtcRq(rqTimeMassIoPoll,0,0,1,8,7777)'		; volume recognition timer'
) FI
)FI' FS

m_temp label byte

org offset nOsProcDesc
DW	m_nOsProcDesc
IF (NOT FS) THEN (
if(ctosp)then(
org offset nSoftwareInt
DW	m_nSoftwareInt
org offset nHardwareInt
DW	m_nHardwareInt
)else(
org offset nRawInt
DW	m_nRawInt
org offset nMediatedInt
DW	m_nMediatedInt
)fi

IF ((m_SysExch+1+nUsrExchange) GE 100h) THEN (
	SET(nUsrExchange, 0FEhm_SysExch)
	IF (PASS1 EQ 1) THEN (
		out(
WARNING: too many exchanges specified  nUsrExchange adjusted to nUsrExchange)
		)FI
)FI
org offset nExchg
DW	m_SysExch+1 + nUsrExchange
org offset userExchFirst
DW	m_SysExch+1
)FI

org offset m_temp

if(ctosp)then(
IF (m_nSoftwareInt EQ 0)        THEN (rgSoftwareIntDesc	label	byte) FI
IF (m_nHardwareInt EQ 0)        THEN (rgHardwareIntDesc    label byte) FI
)else(
IF (m_nRawInt EQ 0)             THEN (rgRawIntDesc	label	byte) FI
IF (m_nMediatedInt EQ 0)        THEN (rgMediatedIntDesc    label byte) FI
)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_nRgMassioDisp EQ 0) THEN (rgMassioDisp label byte) FI
IF (m_nSysCommInt EQ 0) THEN (rgSysCommInt label byte) FI



EVEN
nRgInitRtcRequest	DW	m_nRgInitRtcRequest
nInitProcHardware	DW	m_nInitProcHardware
nInitProcIntDisable	DW	m_nInitProcIntDisable
nInitProcIntEnable	DW	m_nInitProcIntEnable
nRgMassioDisp		DW	m_nRgMassioDisp
initSysDevNum		DW	IF (*IsDef(SysDevNum)) THEN (SysDevNum) ELSE (0FFFFh)FI

IF (NOT FS) THEN (' CTOS
cascade8259		DW	cascade8259
nSysCommInt		DW	m_nSysCommInt
nRequestFileNames	DW	m_nRequestFileNames
iModDescMax		DW	m_iModDescMax
srgExchReal		DB	m_nVirtualExch
fSFNM			DB	IF(fSpecialFullyNestedMode) THEN (0FFh) ELSE (0)FI
)FI

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

*DEFINE (CreateGen)(
EVEN
gen LABEL WORD
DW nPcb,m_SysExch+1 + nUsrExchange,nMsgWait,nPTiming,nMsgWaitReserve
DW nSoftVec
DW nIob,nFcb,nFab,nDcb,nVhb,nUcb,nFub
'sysDeviceNum	'DW 0
'pSysVhb	'DD 0
IF(fMFHardware)THEN(
DD dcb0,dcb1,dcb2,dcb3,dcb4,dcb5
)ELSE(
DD dcb0,dcb1,dcb2,dcb3,dcb4,dcb5,dcb6,dcb7
DD dcb8,dcb9,dcb10,dcb11,dcb12,dcb13,dcb14,dcb15
DD dcb16,dcb17,dcb18,dcb19,dcb20,dcb21,dcb22,dcb23
)FI
)

$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))


;
; end of file sysgen.mdf
;
ssioDisp		DW