SET(TRUE,0FFh)
SET(FALSE,0)
TRUE EQU 0FFh
FALSE EQU 0

SET (nRqNoRemoteTerm,0)
SET (m_nOsProcDesc,  0)
SET (m_nRgInitRtcRequest, 0)
SET (m_nInitProcHardware, 0)
SET (m_nInitProcIntDisable, 0)
SET (m_nInitProcIntEnable, 0)
SET (m_nSetIntHandler,0)
SET (m_nRgMassIo, 0)
SET (nDcbTemplate, 0)
SET (sOsProcStacks, 0)

; WsType definitions:

' Obsolete
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

' Current valid wsTypes
ngenCluster    EQU 7
ngen           EQU 8
ngenMaster     EQU 9
srpCpMaster    EQU 12
srpGpMaster    EQU 20

; ClusterConfig definitions:

standAlone     EQU 0
cluster        EQU 1
master         EQU 2

; HardwareType definitions

FPtype	EQU 10
TPtype	EQU 11
CPtype	EQU 12
SPtype	EQU 13
DPtype	EQU 14
RpType  EQU 15	; obsolete
NpType	EQU 16	; this is Unisys' Np
BtType	EQU 19	; BootTapeOsLoader

GpType	EQU 20
SiType	EQU 21	; Gp with Si board
CiType	EQU 22	; Gp with Ci board
PcType	EQU 4
ClType	EQU 32	; Comarch RS422
APType  EQU 64	; obsolete
AP2Type EQU 65	; obsolete

data SEGMENT PUBLIC 'data'
DGroup GROUP Data

PUBLIC nInitProcHardWare,   rgInitProcHardWare
PUBLIC nInitProcIntDisable, rgInitProcIntDisable
PUBLIC nInitProcIntEnable,  rgInitProcIntEnable
PUBLIC nRgInitRtcRequest,   rgInitRtcRequest
PUBLIC nOSProcDesc,         rgOSProcDesc
PUBLIC nSetIntHandler,      rgSetIntHandler
PUBLIC rgOsTable, endOsTable
PUBLIC iMySlot, wMySlotBits

EVEN
wMySlotBits DW ?        ; SHL(iMySlot,10).
iMySlot DB ?			; Constructed from bMySlot.

data ENDS

;****************************************************************************
; MACRO DEFINITIONS
;****************************************************************************
;
*DEFINE(Begin)(DEFINE(FS)(0FFh)
TCode SEGMENT BYTE PUBLIC 'data'
TCode ENDS
DGroup GROUP TCode
data SEGMENT PUBLIC 'data')
;
;
; EXTRN  declare a label extrn and outside of the data segment.  This will only
; work if called from within segment data.
;
*DEFINE(Extrn(label))('
data ENDS
IF (NOT *ISDEF(label)) THEN ('
EXTRN label:far
)FI'
data SEGMENT PUBLIC 'data'
)

*DEFINE (debl(text)) ('
'
'deblankexpand to text, less leading blanks, up to first blank
'
match(debl1 debl2)(text)'
while(len(debl1) eq 0 AND len(debl2) ne 0)(match(debl1 debl2)(debl2))'
debl1)

' This gets redefined for OS sysgen.
*DEFINE(ResidentDataBoundry(size))(
OsTable		SEGMENT PUBLIC 'Data'
DGroup GROUP OsTable
rgOsTable	DB size DUP(0)
EVEN
endOsTable	DW 0
OsTable		ENDS
)

;
; define the CTOS processes
;
StrSeg SEGMENT PUBLIC 'memory'
PUBLIC rgOSProcName
rgOSProcName LABEL BYTE
StrSeg ENDS

*DEFINE (OsProcName(name))('
OUT(.)
StrSeg SEGMENT
tmp0 EQU OFFSET $
DB	0
DB 'debl(name)'
tmp1 EQU OFFSET $
DB 0	; null terminate list
ORG tmp0
DB tmp1tmp01
ORG tmp1
StrSeg ENDS
)

*DEFINE (OsProcDesc(pEntry, sStack, priority, defaultExch, pCheckProc))(

; pEntry arg contains optional name 
	match(proc  name)(pEntry)

    IF (m_nOsProcDesc EQ 0) THEN(
rgOsProcDesc	LABEL	BYTE
    )FI
		SET(m_nOsProcDesc, m_nOsProcDesc + 1)
		EXTRN(proc)
	IF (NES(pCheckProc, 0)) THEN(
		EXTRN(pCheckProc)
	)FI
		DD	proc
		DW	sStack
		DB	priority
    IF (defaultExch EQ 0) THEN(
		DW	0
    )ELSE(
	IF(FS) THEN(
		DW	defaultExch
	)ELSE(
		DW	SysExch
		NameSysExch(m_ExchLast, SyncpEntry)
	)FI
    )FI
		DD	pCheckProc
		IF ((len(name)) EQ 0) THEN (
		OsProcName(proc)
		)ELSE(
		OsProcName(name)
		)FI
SET(sOsProcStacks, sOsProcStacks + sStack)
)
$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 interrupts
;
*DEFINE(InitProcIntDisable(pEntry))('
IF (m_nInitProcIntDisable EQ 0) THEN ('
rgInitProcIntDisable label byte
)FI'
SET (m_nInitProcIntDisable, m_nInitProcIntDisable+1)'
EXTRN(pEntry)'
DD pEntry
)
$EJECT
sbInitNameSeg	SEGMENT BYTE PUBLIC 'memory'
sbInitNameSeg	ENDS
rgpInitNameSeg	SEGMENT BYTE PUBLIC 'memory'
rgpInitName LABEL DWORD
PUBLIC rgpInitName
rgpInitNameSeg	ENDS

*DEFINE(InitName(name)) (
sbInitNameSeg SEGMENT
m_InitProc EQU OFFSET $
DB LEN(name)
DB 'name'
sbInitNameSeg ENDS

rgpInitNameSeg SEGMENT
	DD	m_InitProc
rgpInitNameSeg ENDS
)
;
; procedures to do after turning on interrupts
;
*DEFINE(InitProcIntEnable(pEntry))('
IF (m_nInitProcIntEnable EQ 0) THEN ('
prgpInitName DD rgpInitName
PUBLIC prgpInitName
rgInitProcIntEnable label byte
)FI'
SET (m_nInitProcIntEnable, m_nInitProcIntEnable+1)'
EXTRN(pEntry)'
DD pEntry
InitName(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
)

'
' System common subroutine entry points
'
*DEFINE(SystemCommon(iProc, pEntry, TCode)) LOCAL m_TCode ('
IF (NOT IsDef(rgSystemCommonInstall)) THEN ('
SET(m_nSystemCommonInstall,0)
PUBLIC nSystemCommonInstall, rgSystemCommonInstall
rgSystemCommonInstall label byte
)FI'

SET(m_nSystemCommonInstall,m_nSystemCommonInstall+1)
DW iProc
EXTRN(pEntry)'
DD pEntry

IF(LEN(TCode) EQ 0) THEN ('
DD 0
DW 0

) ELSE (
TCode SEGMENT BYTE
m_TCode DB 'TCode'
TCode ENDS
DD m_TCode
DW LEN(TCode)
)FI'
)

$EJECT
'
' Interrupt entry points
'
*DEFINE(Interrupt(tyDev, pEntry, fDevice, fRaw))('
IF (NOT IsDef(rgSetIntHandler)) THEN ('
rgSetIntHandler label byte
)FI'

SET(m_nSetIntHandler,m_nSetIntHandler+1)
DW tyDev
EXTRN(pEntry)'
DD pEntry
DB fDevice, fRaw
)

; tyDevice values, also in Interrupts.edf and SysGen.asm.
tyController EQU 0
tyCascade EQU 1
tyCascade2 EQU 2
tyExternal EQU 2
tyPIT EQU 3
tyRTC EQU 4
tyLPT EQU 5
tyKBD EQU 6
tyRS4221 EQU 7
tyRS4222 EQU 8
tyFloppy1 EQU 9
tyWD2010 EQU 10
tySCSI1 EQU 11
tySCSI2 EQU 12
tyDmaTC EQU 13
tyDoorbell EQU 14
tyRS232AB EQU 15
tyRS232CD EQU 16
tyRS232EF EQU 17
tyRS232GH EQU 18
tyCoprocessor EQU 19
tyRedirect EQU 20
tyRS232IJ EQU 21
tyMegabusDma EQU 22
tyEccError EQU 23
tyXINTR0 EQU 24
tyXINTR1 EQU 25
tyFloppy2 EQU 26
tyXINTR3 EQU 27
tyXINTR4 EQU 28
tyHINTR87 EQU 29
tyKbdXmit EQU 30
tyXBusTimeout EQU 31
tyVoice EQU 32
tyHINTR71 EQU 33
tyIRQ5 EQU 34
tyIRQ10 EQU 35
tyIRQ11 EQU 36
tyIRQ15 EQU 37
tyDevLast EQU 37

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

' This macro checks and allocates file system data structures.
*DEFINE (FileSystem(model)) (
SET(fNGen,0)
SET(fSrp,0)
SET(fSI,0)
SET(fFp,0)
SET(fDp,0)

SET(fmodel,0FFh)' Sets one of fNGen, fSI, fFp, fDp, fSrp.

IF (fSI OR fFp OR fDp) THEN (
	SET(fSrp,0FFh)
)FI

If (Not(*Isdef(cbNameSpace))) Then (Define(cbNameSpace)(4096))FI
If (Not(*Isdef(cbNameCompactionGoal))) Then
   (Define(cbNameCompactionGoal)(eval(cbNameSpace2)))FI
	IF (nFab GT 6550) THEN (OUT(nFab must be no greater than 6550.))FI
	IF (nFub GT 4315) THEN (OUT(nFub must be no greater than 4315.))FI

IF (NOT (*ISDEF(fFabUfbOwnSeg))) THEN (
	IF (fSi) THEN (
		SET(fFabUfbOwnSeg,TRUE)
	) ELSE (
		SET(fFabUfbOwnSeg,FALSE)
		IF (nFab GT 1000 OR nFub GT 1000) THEN (
			SET(fFabUfbOwnSeg,TRUE)
			OUT(
'			'With this many FabsFubs, change '
'			'Fs_if(fFp)then(Fp)else(if(fDp)then(Dp)else(N)fi)fi'
'			'.fls to list HfsUfb2 instead of HfsUfb before linking.
'			')
)FI	)FI	)FI

    IF (fFP) THEN (
	IF (Pass1) THEN (
	    IF (*ISDEF(nDisk)) THEN (
		IF ((nDisk LT 1) OR (nDisk GT 4)) THEN (
		    OUT(nDisk must be between 1 and 4)
		) FI
	    ) ELSE (
		OUT(Define nDisk)
	    ) FI
	) FI
    ) FI
    IF (fDP) THEN (
	IF (Pass1) THEN (
	    IF (*ISDEF(nDisk)) THEN (
		IF ((nDisk LT 1) OR (nDisk GT 6)) THEN (
		    OUT(nDisk must be between 1 and 6)
		) FI
	    ) ELSE (
		OUT(Define nDisk)
	    ) FI
	) FI
    ) FI
    IF (fSI) THEN (
	IF (Pass1) THEN (
	    IF (*ISDEF(nDisk)) THEN (
		IF ((nDisk LT 1) OR (nDisk GT 14)) THEN (
		    OUT(nDisk must be between 1 and 14)
		) FI
	    ) ELSE (
		OUT(Define nDisk)
	    ) FI
	) FI
    ) FI

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)
SET (dcb24,0)
SET (dcb25,0)
SET (dcb26,0)
SET (dcb27,0)
SET (dcb28,0)
SET (dcb29,0)
SET (dcb30,0)
SET (dcb31,0)

If (Not(*Isdef(cDiskLogThreshold))) Then (Define(cDiskLogThreshold)(0))FI
If (Not(*Isdef(cSegAllocateMax))) Then (Define(cSegAllocateMax)(0FE00h))FI

IF (NOT (*ISDEF(nDisk))) THEN ( SET(nDisk, 0) ) FI
IF (NOT (*ISDEF(nFloppy))) THEN ( SET(nFloppy, 0) ) FI
IF (NOT (*ISDEF(nMemDisk))) THEN ( SET(nMemDisk, 0) ) FI
IF (NOT (*ISDEF(nSCSI))) THEN ( SET(nSCSI, 0) ) FI

SET(nDcb, nDisk+nFloppy+nMemDisk+nSCSI)
SET(nUpb, nLucb+nDisk)
SET(nScsiIob, nIob+nLucb)
SET(nVhb, nDisk+nFloppy+nMemDisk)

EVEN
; 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.)
PUBLIC wVerBuff, fFsVerify
wVerBuff LABEL WORD
DW 256 DUP (0)
IF (fVerifyFileStruct) THEN (
fFsVerify DW 0FFFh
)ELSE (
fFsVerify DW 0
)FI

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

PUBLIC exchAgent
exchAgent DW 12

PUBLIC qbAllocateMax
qbAllocateMax DW 0,cSegAllocateMax

PUBLIC sgNmbHeap,sNmbHeap,sNmbHeapFree,sNmbCompactionGoal
sgNmbHeap			DW 0; InitFs initializes
sNmbHeap			DW cbNameSpace
sNmbHeapFree		DW cbNameSpace
sNmbCompactionGoal	DW cbNameCompactionGoal

SegMartSeg SEGMENT PUBLIC 'Coed'
signature			DB 'MART'
nSeg				DW 4
rgSeg LABEL WORD
sNmbSeg				DW cbNameSpace
sFcb2Seg			DW nFcb*16			; 32 per fcb. 16 in DGroup, 16 here.
IF(fFabUfbOwnSeg) THEN (
	SET(sMpUserNumOUfbHead,256*2)
	SET(sMpGroupOUfbHead,64*4)
	SET(sRgUfb,nFub*15)
sUfbSeg				DW sMpUserNumOUfbHead+sMpGroupOUfbHead+sRgUfb
sFabSeg				DW 2+nFab*10		; 10 bytes per fab, 2 byte filler
) ELSE (' No FcbUfbFab segs needed
sUfbSeg				DW 0
sFabSeg				DW 0
)FI
SegMartSeg ENDS
SegMartGroup GROUP SegMartSeg

PUBLIC sgSegMart
sgSegMart DW segMartSeg

PUBLIC pFcb2, oFcb, sgFcb2
pFcb2  LABEL DWORD
oFcb   DW 0
sgFcb2 DW 0; InitFs initializes

PUBLIC pMpGroupOUfbHead, sgUfbSeg, sgFabSeg
IF(fFabUfbOwnSeg) THEN (
PUBLIC oMpGroupOUfbHead
pMpGroupOUfbHead LABEL DWORD
oMpGroupOUfbHead DW sMpUserNumOUfbHead
sgUfbSeg DW 0; InitFs initializes
sgFabSeg DW 0; InitFs initializes

EXTRN HfsUfb2: BYTE		; Ensure proper link.  HfsUfb2 PUBLIC in HfsUfb2.obj
HfsDummy DW HfsUfb2		; Must reference it for Assembler to call for it.
) ELSE (' Fabs, Ufbs in DGroup
EXTRN HfsUfb: BYTE		; Ensure proper link.  HfsUfb  PUBLIC in HfsUfb.obj
HfsDummy DW HfsUfb		; Must reference it for Assembler to call for it.

pMpGroupOUfbHead DD 0	; Should never be used
sgUfbSeg DW DGroup
sgFabSeg DW DGroup
)FI' NOT fFabUfbOwnSeg

PUBLIC cDiskLogThreshold
cDiskLogThreshold DW cDiskLogThreshold

Public	pStat, pDiskStat, pCdt
pStat		DD	?
pDiskStat	DD	?
pCdt		DD  ?
;
;  The following is used by MassIo for Sector Scheduling
;
EVEN
Public rgSectMap
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

)' FileSystem

$EJECT
;
; macro for defining MassIo dispatch routines
;
*DEFINE(MassIoInit (pInit)) (
    IF (m_nRgMassIo EQ 0) THEN (
		PUBLIC	rgMassIoInit
rgMassIoInit	LABEL	BYTE
    ) FI
    SET (m_nRgMassIo, m_nRgMassIo+1)
    IF (EQS(Dummy,pInit)) THEN (
 		DD	0
    ) ELSE (
		EXTRN(pInit)
		DD		pInit
    ) FI
)

*DEFINE(MassIoDone) (
			PUBLIC	rgMassIoDisp, rgMassIoISR, rgMassIoWatchdog

rgMassIoDisp		DD	m_nRgMassIo DUP (0)
rgMassIoISR		DD	m_nRgMassIo DUP (0)
rgMassIoWatchdog	DD	m_nRgMassIo DUP (0)

			PUBLIC	rgCreateDcb, rgEavesdropPassword, rgUpdateResourceName
			PUBLIC	rgQueryDiskGeometry, rgSetDiskGeometry

rgCreateDcb		DD	m_nRgMassIo DUP (0)
rgEavesdropPassword	DD	m_nRgMassIo DUP (0)
rgUpdateResourceName DD	m_nRgMassIo DUP (0)
rgQueryDiskGeometry	DD	m_nRgMassIo DUP (0)
rgSetDiskGeometry	DD	m_nRgMassIo DUP (0)
)

$EJECT
; The next macro, DcbTemplate, defines device control blocks (DCB's) for devices
; controlled by the File System, ONLY.  These include devices of the types
; described below which (conventionally) have the names indicated below.
;
;	Floppy disks			F0, F1, ...
;	    (either floppy or SCSI interfaces)
;	Rigid disks			D0, D1, ...
;	    (either SMD, ST506 or SCSI interfaces)
;	Memory disks			M0, M1, ...
;	Miscellaneous devices		S0, S1, ...
;
; Note that SCSI devices (such as quarterinch tape) that are NOT mass storage
; devices and hence not dispatched by MassIo DO NOT REQUIRE this kind of DCB.
; For compatability reasons with DoDirectReadDoDirectWrite, sequential SCSI
; devices are assigned DCB's in the miscellaneous device category.

rigidDisk	EQU	0
floppyDisk	EQU	1
memDisk		EQU	2
miscDevice	EQU	3


*DEFINE(DcbTemplate(devFamily, devName, devPassword, retryLimit)) (

SET(nDcbTemplate, nDcbTemplate+1)

IF (nDcbTemplate EQ 1) THEN ( DEFINE(dcb)(0) ) FI
IF (nDcbTemplate EQ 2) THEN ( DEFINE(dcb)(1) ) FI
IF (nDcbTemplate EQ 3) THEN ( DEFINE(dcb)(2) ) FI
IF (nDcbTemplate EQ 4) THEN ( DEFINE(dcb)(3) ) FI
IF (nDcbTemplate EQ 5) THEN ( DEFINE(dcb)(4) ) FI
IF (nDcbTemplate EQ 6) THEN ( DEFINE(dcb)(5) ) FI
IF (nDcbTemplate EQ 7) THEN ( DEFINE(dcb)(6) ) FI
IF (nDcbTemplate EQ 8) THEN ( DEFINE(dcb)(7) ) FI
IF (nDcbTemplate EQ 9) THEN ( DEFINE(dcb)(8) ) FI
IF (nDcbTemplate EQ 10) THEN ( DEFINE(dcb)(9) ) FI
IF (nDcbTemplate EQ 11) THEN ( DEFINE(dcb)(10) ) FI
IF (nDcbTemplate EQ 12) THEN ( DEFINE(dcb)(11) ) FI
IF (nDcbTemplate EQ 13) THEN ( DEFINE(dcb)(12) ) FI
IF (nDcbTemplate EQ 14) THEN ( DEFINE(dcb)(13) ) FI
IF (nDcbTemplate EQ 15) THEN ( DEFINE(dcb)(14) ) FI
IF (nDcbTemplate EQ 16) THEN ( DEFINE(dcb)(15) ) FI
IF (nDcbTemplate EQ 17) THEN ( DEFINE(dcb)(16) ) FI
IF (nDcbTemplate EQ 18) THEN ( DEFINE(dcb)(17) ) FI
IF (nDcbTemplate EQ 19) THEN ( DEFINE(dcb)(18) ) FI
IF (nDcbTemplate EQ 20) THEN ( DEFINE(dcb)(19) ) FI
IF (nDcbTemplate EQ 21) THEN ( DEFINE(dcb)(20) ) FI
IF (nDcbTemplate EQ 22) THEN ( DEFINE(dcb)(21) ) FI
IF (nDcbTemplate EQ 23) THEN ( DEFINE(dcb)(22) ) FI
IF (nDcbTemplate EQ 24) THEN ( DEFINE(dcb)(23) ) FI
IF (nDcbTemplate EQ 25) THEN ( DEFINE(dcb)(24) ) FI
IF (nDcbTemplate EQ 26) THEN ( DEFINE(dcb)(25) ) FI
IF (nDcbTemplate EQ 27) THEN ( DEFINE(dcb)(26) ) FI
IF (nDcbTemplate EQ 28) THEN ( DEFINE(dcb)(27) ) FI
IF (nDcbTemplate EQ 29) THEN ( DEFINE(dcb)(28) ) FI
IF (nDcbTemplate EQ 30) THEN ( DEFINE(dcb)(29) ) FI
IF (nDcbTemplate EQ 31) THEN ( DEFINE(dcb)(30) ) FI
IF (nDcbTemplate EQ 32) THEN ( DEFINE(dcb)(31) ) FI

DEFINE(dcbdcb)(dcbdcb)

dcbdcb		LABEL	BYTE
		DB	devFamily	'deviceClass'
		DB	0		'fUsed'
		DB	LEN(devName),'devName',12LEN(devName) DUP (0)
		DB	LEN(devPassword),'devPassword',12LEN(devPassword) DUP (0)
		DW	retryLimit	'retryLimit'
)

$EJECT

*Define(SetScsiMgrVendorId(Vendor))(
  IF (Len(Vendor) NE 8) THEN (
      Error(ScsiMgrVendorId must be exactly 8 characters long)
  ) ELSE (
      PUBLIC	rgbScsiMgrVendorId
      rgbScsiMgrVendorId DB 'Vendor'
  )FI
)

*Define(SetScsiMgrProductId(Product))(
  IF (Len(Product) NE 16) THEN (
      Error(ScsiMgrProductId must be exactly 16 characters long)
  ) ELSE (
      PUBLIC	rgbScsiMgrProductId
      rgbScsiMgrProductId DB 'Product'
  )FI
)

*Define(SetScsiMgrVersion(Version))(
  IF (Len(Version) NE 4) THEN (
      Error(ScsiMgrVersion must be exactly 4 characters long)
  ) ELSE (
      PUBLIC	rgbScsiMgrVersion
      rgbScsiMgrVersion DB 'Version'
  )FI
)

*DEFINE (CreateGen)(
EVEN
PUBLIC gen
; SysGenType is defined in CtosTypes.edf
gen LABEL WORD
DW 'JF'
IF (not(*Isdef(nUcb))) THEN (DW 0) ELSE (DW nUcb) FI
IF (not(*Isdef(nPcb))) THEN (DW 0) ELSE (DW nPcb) FI
IF (not(*Isdef(nUsrExchange))) THEN (DW 0) ELSE (DW nUsrExchange) FI
IF (not(*Isdef(nMsgWait))) THEN (DW 0) ELSE (DW nMsgWait) FI
IF (not(*Isdef(nPTiming))) THEN (DW 0) ELSE (DW nPTiming) FI
IF (not(*Isdef(nSoftVec))) THEN (DW 0) ELSE (DW nSoftVec) FI
IF (not(*Isdef(nIob))) THEN (DW 0) ELSE (DW nIob) FI
IF (not(*Isdef(nFcb))) THEN (DW 0) ELSE (DW nFcb) FI
IF (not(*Isdef(nFab))) THEN (DW 0) ELSE (DW nFab) FI
IF (not(*Isdef(nDcb))) THEN (DW 0) ELSE (DW nDcb) FI
IF (not(*Isdef(nVhb))) THEN (DW 0) ELSE (DW nVhb) FI
IF (not(*Isdef(nMemDisk))) THEN (DW 0) ELSE (DW nMemDisk) FI
IF (not(*Isdef(nFub))) THEN (DW 0) ELSE (DW nFub) FI
IF (not(*Isdef(nScsiIob))) THEN (DW 0) ELSE (DW nScsiIob) FI
IF (not(*Isdef(nLucb))) THEN (DW 0) ELSE (DW nLucb) FI
IF (not(*Isdef(nUpb))) THEN (DW 0) ELSE (DW nUpb) FI
IF (not(*Isdef(dcb0))) THEN (DD 0) ELSE (DD dcb0) FI
IF (not(*Isdef(dcb1))) THEN (DD 0) ELSE (DD dcb1) FI
IF (not(*Isdef(dcb2))) THEN (DD 0) ELSE (DD dcb2) FI
IF (not(*Isdef(dcb3))) THEN (DD 0) ELSE (DD dcb3) FI
IF (not(*Isdef(dcb4))) THEN (DD 0) ELSE (DD dcb4) FI
IF (not(*Isdef(dcb5))) THEN (DD 0) ELSE (DD dcb5) FI
IF (not(*Isdef(dcb6))) THEN (DD 0) ELSE (DD dcb6) FI
IF (not(*Isdef(dcb7))) THEN (DD 0) ELSE (DD dcb7) FI
IF (not(*Isdef(dcb8))) THEN (DD 0) ELSE (DD dcb8) FI
IF (not(*Isdef(dcb9))) THEN (DD 0) ELSE (DD dcb9) FI
IF (not(*Isdef(dcb10))) THEN (DD 0) ELSE (DD dcb10) FI
IF (not(*Isdef(dcb11))) THEN (DD 0) ELSE (DD dcb11) FI
IF (not(*Isdef(dcb12))) THEN (DD 0) ELSE (DD dcb12) FI
IF (not(*Isdef(dcb13))) THEN (DD 0) ELSE (DD dcb13) FI
IF (not(*Isdef(dcb14))) THEN (DD 0) ELSE (DD dcb14) FI
IF (not(*Isdef(dcb15))) THEN (DD 0) ELSE (DD dcb15) FI
IF (not(*Isdef(dcb16))) THEN (DD 0) ELSE (DD dcb16) FI
IF (not(*Isdef(dcb17))) THEN (DD 0) ELSE (DD dcb17) FI
IF (not(*Isdef(dcb18))) THEN (DD 0) ELSE (DD dcb18) FI
IF (not(*Isdef(dcb19))) THEN (DD 0) ELSE (DD dcb19) FI
IF (not(*Isdef(dcb20))) THEN (DD 0) ELSE (DD dcb20) FI
IF (not(*Isdef(dcb21))) THEN (DD 0) ELSE (DD dcb21) FI
IF (not(*Isdef(dcb22))) THEN (DD 0) ELSE (DD dcb22) FI
IF (not(*Isdef(dcb23))) THEN (DD 0) ELSE (DD dcb23) FI
IF (not(*Isdef(dcb24))) THEN (DD 0) ELSE (DD dcb24) FI
IF (not(*Isdef(dcb25))) THEN (DD 0) ELSE (DD dcb25) FI
IF (not(*Isdef(dcb26))) THEN (DD 0) ELSE (DD dcb26) FI
IF (not(*Isdef(dcb27))) THEN (DD 0) ELSE (DD dcb27) FI
IF (not(*Isdef(dcb28))) THEN (DD 0) ELSE (DD dcb28) FI
IF (not(*Isdef(dcb29))) THEN (DD 0) ELSE (DD dcb29) FI
IF (not(*Isdef(dcb30))) THEN (DD 0) ELSE (DD dcb30) FI
IF (not(*Isdef(dcb31))) THEN (DD 0) ELSE (DD dcb31) FI
DD 0 ; Endsentinel for Initfs(AssignDcb)
)

*DEFINE (Final)(

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_nSystemCommonInstall EQ 0)THEN (rgSystemCommonInstall  label byte) FI
IF (m_nSetIntHandler EQ 0)      THEN (rgSetIntHandler  label byte) FI
IF (m_nOsProcDesc EQ 0)  THEN (rgOsProcDesc  label byte) FI
IF (m_nRgInitRtcRequest EQ 0) THEN(rgInitRtcRequest label byte) FI

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

data ENDS
END
); end macro Final

Template EQ 30) THEN ( DEFINE(dcb)(29) ) FI
IF (nDcbTemplate EQ 31) THEN ( DEFINE(dcb)(30) ) FI
IF (nDcbTemplate EQ 32) THEN ( DEFINE(dcb