;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	TITLE:		bs3cnf.inc
;
;	ABSTRACT:	Macro definition for third stage configuration
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
dgroup    group   data
cgroup    group   code
assume    cs:cgroup

data      segment para public 'data'
dev_table label  byte
public    dev_table
data      ends

code      segment para public 'code'
extrn     bs3:near
extrn     cpyrt:near
;
;	do something with the copyright to pull it in.
	dw	cpyrt

code      ends

%'
%'	Set up the default iSDM address values.
%'
%SET(restart_base_hi, 0FFFFH)
%SET(restart_base_lo, 0FF80H)
%SET(code_base_hi, 0FFFFH)
%SET(code_base_lo, 08240H)

%'	TRIM and ARG are utility macros
%'
%'  TRIM(a) - returns the input parameter trimmed of leading and
%'	 trailing blanks.
%*DEFINE(TRIM(a)) LOCAL x y (%MATCH( x y)(%a)%x)%'
%' 
%'   ARG -  gets the next comma-delimited arg from variable named TAIL,
%'	stripped and trimmed.  Any macro that has a valid type of NONE
%'	uses this macro so that the other parameters are not needed.
%*DEFINE(ARG) LOCAL a (%MATCH(a,tail)(%tail)%TRIM(%a))%'
%' 

%DEFINE(extrn_list) ()

%*DEFINE(external(target,extrn_type)) LOCAL a b (%'
%MATCH(a,b)(%extrn_list)%'
%'
%SET(result,-1)%'
%WHILE(%LEN(%a) NE 0) (%'
%'	'%IF(%EQS(%target,%a)) THEN(%'
%'		'%SET(result,0)%'
%'	')FI %'
%'
%'	'%MATCH(a,b)(%b)%'
)%'
%'
%IF(%result) THEN(%'
%'	'%DEFINE(extrn_list) (%target,%extrn_list) %'
	extrn	%target	: %extrn_type
)FI %'
%'
)%'

%*DEFINE(remote_device(parameters))(%DEFINE(tail)(%parameters)%'
%DEFINE(device_name) (%ARG)%'
%DEFINE(device_3rd_stage) (%ARG)%'
%DEFINE(dataseg) (%ARG)%'
%external(%device_3rd_stage,far)%'
%external(%dataseg,dword)%'

data	segment
db	':%device_name:'
dd	%device_3rd_stage
data	ends
)

%*DEFINE(device(parameters))(%DEFINE(tail)(%parameters)%'
%DEFINE(unit_no) (%ARG)%'
%DEFINE(device_name) (%ARG)%'
%DEFINE(device_init) (%ARG)%'
%DEFINE(device_read) (%ARG)%'
%DEFINE(dataseg) (%ARG)%'
%DEFINE(unit_info) (%ARG)%'
%IF (%LEN (%unit_info) EQ 0) THEN (%'
%'	'%DEFINE(unit_info)(0)%'
)ELSE (%'
%'	'%external(%unit_info,far)%'
) FI%'
%external(%device_init,far)%'
%external(%device_read,far)%'
%external(%dataseg,dword)%'

data	segment
db	':%device_name:'
dd	%device_init
dd	%device_read
dd	%dataseg
dd	%unit_info
data	ends
)
;
%*DEFINE (end)(
data      segment
dw	0,0,0,0
data      ends
code	segment
			public	dmon_config_table
			public	sdm_restart_base
			public	sdm_code_base
dmon_config_table	dw	00H, 040H		; 0400H
sdm_restart_base	dw	%restart_base_lo, %restart_base_hi
sdm_code_base		dw	%code_base_lo, %code_base_hi

code	ends
end)
;
%*DEFINE (int3)(
data      segment
intx      label   byte
public    intx
db	03h
data      ends
)
;
%*DEFINE (int1)(
data      segment
intx      label   byte
public    intx
db	01h
data      ends
)
;
%*DEFINE (halt)(
data      segment
intx      label   byte
public    intx
db	0h
data      ends
)
;
%*DEFINE  (cpu_board(type))(%'
%DEFINE(cpu_type)(%type)
%'	'%IF ((%EQS(%type,386/20)) OR (%EQS(%type,386/30))) THEN (
%'		'data_bs218    segment    para public 'DATA'
%'		'public delay_const218
%'		'delay_const218 dw 02000h
%'		'data_bs218    ends

%'		'data_bsmsc    segment    para public 'DATA'
%'		'public delay_constmsc
%'		'delay_constmsc dw 02000h
%'		'data_bsmsc    ends

%'		'data_bscsi    segment    para public 'DATA'
%'		'public delay_constscsi
%'		'delay_constscsi dw 02000h
%'		'data_bscsi    ends

%'		'code     segment
;
%'		'public   init_board
%'		'init_board proc near
%'		'mov al, 1
%'		'out 0e0h, al
%'		'ret
%'		'init_board  endp

%'		'code	ends
%'		'code     segment

%'		'public   set_mem

%'		'set_mem proc near
%'		'ret
%'		'set_mem  endp

%'		'code	ends
%'	')%'
%'	'ELSE (%IF ((%EQS(%type,386/12)) OR (%EQS(%type,486/12))) THEN (
%'		'data_bs218    segment    para public 'DATA'
%'		'public delay_const218
%'		'delay_const218 dw 02000h
%'		'data_bs218    ends

%'		'data_bsmsc    segment    para public 'DATA'
%'		'public delay_constmsc
%'		'delay_constmsc dw 02000h
%'		'data_bsmsc    ends

%'		'data_bscsi    segment    para public 'DATA'
%'		'public delay_constscsi
%'		'delay_constscsi dw 02000h
%'		'data_bscsi    ends

%'		'code     segment
;
%'		'public   init_board
%'		'init_board proc near
%'		'xor ax, ax
%'		'out 0cah, ax
%'		'ret
%'		'init_board  endp

%'		'code	ends

%'		'code     segment

%'		'public   set_mem

%'		'set_mem proc near
%'		'ret
%'		'set_mem  endp

%'		'code	ends
%'	')%'
%'	'ELSE (%IF (%EQS(%type,386/100)) THEN (
%'		'data_bs218    segment    para public 'DATA'
%'		'public delay_const218
%'		'delay_const218 dw 02000h
%'		'data_bs218    ends

%'		'data_bsmsc    segment    para public 'DATA'
%'		'public delay_constmsc
%'		'delay_constmsc dw 02000h
%'		'data_bsmsc    ends

%'		'data_bscsi    segment    para public 'DATA'
%'		'public delay_constscsi
%'		'delay_constscsi dw 02000h
%'		'data_bscsi    ends

%'		'code     segment

%'		'public   init_board

%'		'init_board proc near
%'		'ret
%'		'init_board  endp

%'		'code	ends

%'		'code     segment

%'		'public   set_mem

%'		'set_mem proc near
%'		'ret
%'		'set_mem  endp

%'		'code	ends

%'	')%'

%'	'ELSE (%IF ((%EQS(%type,286/100)) OR (%EQS(%type,286/100A)) OR%'
%'		'(%EQS(%type,286/100a)) ) THEN (
%'		'data_bs218    segment    para public 'DATA'
%'		'public delay_const218
%'		'delay_const218 dw 02000h
%'		'data_bs218    ends

%'		'data_bscsi    segment    para public 'DATA'
%'		'public delay_constscsi
%'		'delay_constscsi dw 02000h
%'		'data_bscsi    ends

%'		'code     segment

%'		'public   init_board

%'		'init_board proc near
%'		'ret
%'		'init_board  endp

%'		'code	ends
%'		'code segment public 'code'
%'		'EXTRN set_lbx_mem: near
%'		'code ends

%'		'code     segment
%'		'public   set_mem

%'		'set_mem proc near
%'		'CALL set_lbx_mem
%'		'ret
%'		'set_mem  endp

%'		'code	ends

%'	')%'
%'	'ELSE (%IF (%EQS(%type,system_120) OR %EQS(%type,SYSTEM_120)) THEN (
%'		'%SET(restart_base_hi, 0000EH)
%'		'%SET(restart_base_lo, 0FF80H)
%'		'%SET(code_base_hi, 0000EH)
%'		'%SET(code_base_lo, 08240H)
%'
%'		'b120f_data    segment    word public 'DATA'
%'		'public delay_const120f
%'		'delay_const120f dw 03C00h
%'		'b120f_data    ends
%'
%'		'code     segment
%'		'public   init_board
%'		'init_board proc near
init1:		in		al,64H
		test		al,02H
		jnz		init1
		mov		al,0d1h
		out		64h,al
init2:		in		al,64H
		test		al,02H
		jnz		init2
		mov		al,0dfh
		out		64h,al
init3:		in		al,64H
		test		al,02H
		jnz		init3
		ret
%'		'init_board  endp
%'
%'		'public   set_mem
%'		'set_mem proc near
%'		'ret
%'		'set_mem  endp
%'		'code	ends
%'
%'	')%'

%'	'ELSE (	%' 286/10(A)/12/14/16 CPU boards
%'		'data_bs218    segment    para public 'DATA'
%'		'public delay_const218
%'		'delay_const218 dw 0f00h
%'		'data_bs218    ends

%'		'data_bsmsc    segment    para public 'DATA'
%'		'public delay_constmsc
%'		'delay_constmsc dw 0f00h
%'		'data_bsmsc    ends

%'		'data_bscsi    segment    para public 'DATA'
%'		'public delay_constscsi
%'		'delay_constscsi dw 0f00h
%'		'data_bscsi    ends

%'		'data_b552a    segment    para public 'DATA'
%'		'public delay_const552a
%'		'delay_const552a dw 0f00h
%'		'data_b552a    ends

%'		'code     segment

%'		'public   init_board
%'		'init_board proc near
%'		'xor ax, ax
%'		'out 0cah, ax
%'		'ret
%'		'init_board  endp

%'		'code	ends

%'		'code     segment

%'		'public   set_mem

%'		'set_mem proc near
%'		'ret
%'		'set_mem  endp

%'		'code	ends
%'	') FI %'
%'	') FI %'
%'	') FI %'
%'	') FI %'
%'	') FI %'
)


;
%*DEFINE  (installation(y_or_n))(
%IF ((%EQS(%y_or_n,y)) OR (%EQS(%y_or_n,Y))) THEN (
;
code     segment
;
message	db 'Insert the '
%IF (%EQS(%cpu_type,386/20)) THEN (
	db 'System 320 '
)%'
ELSE (%IF (%EQS(%cpu_type,386/30)) THEN (
	db 'Multibus I '
)%'
ELSE (%IF (%EQS(%cpu_type,386/12)) THEN (
	db 'Multibus I '
)%'
ELSE (%IF (%EQS(%cpu_type,386/100)) THEN (
	db 'SYPMDP '
)%'
ELSE (%IF ((%EQS(%cpu_type,286/100)) OR (%EQS(%cpu_type,286/100A)) OR%'
%'		'(%EQS(%cpu_type,286/100a)) ) THEN (
	db 'SYPMDP '
)%'
ELSE (%IF (%EQS(%cpu_type,system_120) OR %EQS(%cpu_type,SYSTEM_120)) THEN (
	db 'System 120 '
)%'
ELSE (	%' 286/10(A)/12/14/16 CPU boards
	db 'System 310AP '
) FI %'
) FI %'
) FI %'
) FI %'
) FI %'
) FI %'

%IF (%EQS(%cpu_type,386/100)) THEN (
	db 'Start-up Commands diskette and type: go<RETURN>',0dh,0ah,0
)%'
ELSE (
	db 'Start-up Commands diskette and type: g<RETURN>',0dh,0ah,0
) FI %'
;
public	installation
extrn	putstring: near

;
installation proc near

	lea	bx, message
	push	cs
	push	bx
	call	putstring 

	int 3

ret

installation  endp
;
code	ends
)
ELSE (
;
code     segment
;
public	installation
;
installation proc near
;  Nothing to do
ret
installation  endp
;
code	ends
) FI )
