****************************************************
;		MACRO'S TO DEFINE SYSTEM TABLES
;
; 02.37 kls 02/17/82 for I/OS 02.37 and later
; 02.38 sbw 05/03/82 SG rev 03.06
; 02.40 sbw 08/10/82 I/OS rev 02.40
; 02.42 sbw 12/16/82 I/OS rev 02.42
;
;    SERIAL	SERIAL#	   === IN THE RANGE 0 - 65535	; 02.37
;
;    SINIT	[entry-name]	
;     === entry-name is INIT or BYE, creates entry point
;    CINIT	[routine]
;     === CALL to external routine as part of INIT or BYE
;    EINIT
;     === End of INIT or BYE calls
;
;    NOBOOT	[]		- supply rboot entry
;
;    DISKS	[NDRIVES,INITIAL-DISK]
;          	        - NUMBER OF DISK DRIVES, and initial disk 
;
;    DSKx4	[UNIT,CLUSTER SIZE,DUCB,DIR START,SEQ,#CLUS,UCB]
;			- ONE FOR EACH DRIVE
;	x=F 	I/OS rev 02.xx floppy
;	x=H	I/OS rev 02.xx Hard disk
;       x=S	SUB-DIRECTORY (ALL PARAMETERS IGNORED)	02.37
;
;    USR1P	disk,'BOOT-PGM.COM',RES/NRES			;02.42
;    USR1I	dcom,'BOOT-PGM.COM',RES/NRES,dbat		;02.42
;
;	Either USR1P or USR1I may be used. Future versions of SG may
;	use USR1I to specify different DCOM and DBAT units.  The current
;	version of SG uses USR1P and specifies the same unit (parameter
;	"disk" above) for both DCOM and DBAT.
;
;    DEFDEV	[CON,CTL,RDR,PUN,LST,CLK]
;			- DEFINE ALL DEVICE DRIVERS
;    TIMER	[COUNT] - 1 MS. TIMING LOOP 
;    BUFFS	[COUNT] - ALLOCATE SYSTEM BUFFERS
;    EIMAC	[INSTR] - SET GENERAL INTERRUPT MODE
;
;*****************************************************
	LST	NPRT
;
;	Initializations for error checking.
;
?SRIAL	EQU	0
?SDVT	EQU	0
?DISKS	EQU	0
?SDT	EQU	0
?NDSK	EQU	0
?CDSK	EQU	0
?DSDT	EQU	0
?DSDTX	EQU	0
?TDEF	EQU	0
?BDEF	EQU	1	; Not currently used [03.06]
?EIDEF	EQU	0
?IINIT	EQU	0
?vinit	equ	1	; Flag controlling assembly of INIT	;02.40
?vbye	equ	0	; Falg controlling assembly of BYE	;02.40
;
SERIAL	MAC	; ESTABLISH LOCAL SERIAL NUMBER
[	ENT	SERNUM
SERNUM:	DW	0&1	; SERIAL NUMBER CONSTANT
?SRIAL	EQU	1
]
;
SINIT	MAC		; INIT or BYE entry point
[	ifc	?v&1	; BYE no longer assembled here		;02.40
	ENT	&1
&1:
?I&1	EQU	1
	endc							;02.40
;
]
;
CINIT	MAC		; INIT or BYE routine
[	EXT	&1
	CALL	&1
;
]
;
EINIT	MAC		; End of INIT or BYE sequence
[	RET
;
]
;
NOBOOT	MAC		; DUMMY RBOOT
[	ENT	RBOOT
RBOOT:	JMP	RBOOT
]
;
; START OF SDT
;
DISKS	MAC	; DOSDT [NUMBER OF DRIVES, INITIAL DISK]
[	ENT	SDT
SDT:	DB	&1
;
?DISKS	EQU	1
?NDSK	EQU	&1
]
;
; UNIT,CLUSTER SIZE,DUCB,DIR START BLK,SEQ
;	MAP IS DEFINED AS RAM SEG
;
DSKF4	MAC	;REVISED SDT, VER 02.00
[	DB	&2	;FLAGS
	DB	0	;STATUS
	DB	&1	;UNIT NUMBER
	DB	0	;TRACK
	DB	8	;CLUSTER SIZE
	EXT	&3
	DW	&3	;DISK UNIT CONTROL BLOCK
	DW	&4	;DIRECTORY START BLOCK
	DB	0,0,0
	DB	'........'
	DW	UN&5MAP,0,0
	DW	&6	;CLUSTERS PER DISK
;
	RAM
UN&5MAP:	DS	&6+7/8
	ROG
;
?SDT	EQU	1
?CDSK	EQU	?CDSK+1
;
]
;
DSKH4	MAC	;REVISED SDT, VER 02.00, HARD DISK
[	DB	&2	;FLAGS
	DB	0	;STATUS
	DB	&1	;UNIT NUMBER
	DB	0	;TRACK
	DB	8	;CLUSTER SIZE
	EXT	&3
	DW	&3	;DISK UNIT CONTROL BLOCK
	DW	&4	;DIRECTORY START BLOCK
	DB	0,0,2
	DB	'........'
	DW	UN&5MAP ;MAP PTR
	DW	&7	;UNIT CONTROL BLOCK PTR
	DW	0
	DW	&6	;CLUSTERS PER DISK
;
	RAM
UN&5MAP:	DS	4
	ROG
;
?SDT	EQU	1
?CDSK	EQU	?CDSK+1
	IFC	&7<>0
?DSDT	EQU	1
	ENDC
;
]
;
DSKS4	MAC		;SUB-UNIT
[	DB	0	;FLAGS
	DB	0	;STATUS
	DB	0	;UNIT NUMBER
	DB	0,8	;TRACK, CLUSTER SIZE
	DW	0,52	;DUCB, DIR START
	DB	64,2	;DIR LENGTH, # CLUSTERS
	DB	80H	;===SUBDIRECTORY===
	DB	'........'	; LABEL
	DW	0,0,0,0
;	DATA FILLED IN FROM MASTER SDT AT INIT TIME
?CDSK	EQU	?CDSK+1
]
;
;KONAN UCB DEFINITION
KONUCB	MAC		; [UCB TAG(0..7), HI HEAD]
[
KON&1:	DB	3FH,-1
	DB	3,32H	; TRACKS (H,L)
	DB	0&2,63,-1
	DW	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
;
?DSDTX	EQU	1
;
]
;
USR1P	MAC		; Initial DCOM/DBAT, NOPI, & RES	;02.42
[;
	ENT	PGMDSK
pgmdsk:	db	('&1'-'A'+1),('&1'-'A'+1)			;02.42
;
	ENT	BOOTNM
BOOTNM:	DB	&2,0
	ds	12-($-bootnm)		;02.40
	db	0			;02.40
;
ZZZRES	EQU	1
ZZZNRES	EQU	0
;
	ENT	OPIRES
OPIRES	EQU	ZZZ&3
;
]
;
USR1I	MAC		; Initial DCOM, NOPI, Resident, DBAT	;02.42
[;
	ENT	PGMDSK
pgmdsk:	db	('&1'-'A'+1),('&4'-'A'+1)			;02.42
;
	ENT	BOOTNM
BOOTNM:	DB	&2,0
	ds	12-($-bootnm)		;02.40
	db	0			;02.40
;
ZZZRES	EQU	1
ZZZNRES	EQU	0
;
	ENT	OPIRES
OPIRES	EQU	ZZZ&3
;
]
;
;   DEFINE SYSTEM DEVICE TABLE
;
DEFDEV	MAC	; DEF [CON,CTL,RDR,PUN,LST,CLK]
[
	ENT	SDVT
;
;	SYSTEM DEVICE TABLE
;
	EXT	&1,&2,&3
	EXT	&4,&5,&6
;
SDVT:	DW	&1,&2,&3
	DW	&4,&5,&6
;
?SDVT	EQU	1
;
]
;
; 	1MS. TIMING LOOP
;
TIMER	MAC	; TIMER [COUNT]
[;
	ENT	DELAY
;
; MACHINE DEPENDENT TIMING LOOP
;
DELAY:	PUSH	B
;
DELAY2:	MVI	C,&1
DELAY3:	NOP
	NOP
	NOP
	DCR	C
	JNZ	DELAY3	; 1MS. HERE
	DCR	A
	JNZ	DELAY2
;
	POP	B
	RET
;
?TDEF	EQU	1
;
]
;  ALLOCATE BUFFERS
BUFFS	MAC	;[NUMBER OF BUFFERS]
[
	RAM
	ENT	NBUFFS,SBUFFS
NBUFFS	EQU	&1
SBUFFS:	DS	NBUFFS*144  

	ROG
;
?BDEF	EQU	1
;
]
;
;CONTROL INTERRUPT STATE
EIMAC	MAC	;[INSTRUCTION: EI OR NOP]
[
	ENT	EIINST,DIINST
EIINST:	&1
	RET
DIINST:	DI
	RET
;
?EIDEF	EQU	1
;
]
;
ERRB	MAC
[	LST	PRT
	ORA	**** **** **** **** **** **** **** **** ****
]
;
ERRE	MAC
[	ORA	**** **** **** **** **** **** **** **** ****
	LST	NPRT
]
;
ENDSDT	MAC
[	LST	NPRT
	IFC	?SRIAL<>1
	ERRB
	ORA	**** ERROR- SERIAL NUMBER MACRO MISSING ****
	ERRE
	ENDC
	IFC	?SDVT<>1
	ERRB
	ORA	**** ERROR - 'DEFDEV' MACRO MISSING     ****
	ERRE
	ENDC
	IFC	?DISKS<>1
	ERRB
	ORA	**** ERROR - MISSING 'DISKS' MACRO ****
	ERRE
	ENDC
	IFC	?SDT<>1
	ERRB
	ORA	**** ERROR - AT LEAST ONE 'DSKH4' OR 'DSKF4' MACRO REQ'D ****
	ERRE
	ENDC
	IFC	?NDSK<>?CDSK
	ERRB
	ORA	**** ERROR - INCORRECT NUMBER OF DISK UNITS DEFINED ****
	ERRE
	ENDC
	IFC	?DSDT<>?DSDTX
	ERRB
	ORA	**** ERROR - 'DSKH4'  AND 'DSKUCB' MACRO MISMATCH ****
	ERRE
	ENDC
	IFC	?TDEF<>1
	ERRB
	ORA	**** ERROR - 'TIMER' DEFINITION MISSING ****
	ERRE
	ENDC
	IFC	?BDEF<>1
	ERRB
	ORA	**** ERROR - BUFFER  DEFINITION MISSING ****
	ERRE
	ENDC
	IFC	?EIDEF<>1
	ERRB
	ORA	**** ERROR -  ENABLE DEFINITION MISSING ****
	ERRE
	ENDC
	IFC	?IINIT<>1
	ERRB
	ORA	**** ERROR -  INIT  MACRO  MISSING ****
	ERRE
	ENDC
;			; Test for BYE removed 02.40
]
	LST	PRT,NASC
