; PCInhibit030 v1.0 (17.4.95)
; (c) by Martin Berndt
;
; TAB-Size: 10

START	move.l	$4.w,a6
	cmpi.w	#37,LIB_VERSION(a6)
	bcs.s	Quit
	jsr	_LVOForbid(a6)
	move.w	AttnFlags(a6),d0
	btst	#AFB_68030,d0
	beq.s	Quit0
	btst	#AFB_68040,d0
	bne.s	Quit0
	lea	LibList(a6),a0
	lea	expname(pc),a1
	jsr	_LVOFindName(a6)
	tst.l	d0
	beq.s	Quit0
	move.l	d0,a4
	exg	a4,a6
	moveq	#1,d2
	lea	Products(pc),a2
loop1	suba.l	a0,a0
	movem.l	(a2)+,d0-d1
	jsr	_LVOFindConfigDev(a6)
	tst.l	d0
	bne.s	FoundCD
	dbf	d2,loop1
	bra.s	Quit0
FoundCD	exg	a4,a6
	move.l	d0,a0
	movem.l	cd_BoardAddr(a0),d5-d6
	tst.l	d5
	beq.s	Quit0
	lea	GetTC(pc),a5
	jsr	_LVOSupervisor(a6)
	move.l	d0,d7
	bpl.s	Quit0
	lea	TC_REGs(pc),a0
	moveq	#3,d0
	moveq	#0,d4
loop2	cmp.l	(a0)+,d7
	beq.s	Main
	addq.l	#1,d4
	dbf	d0,loop2
Quit0	jsr	_LVOPermit(a6)
Quit	moveq	#0,d0
	rts

Main	jsr	_LVODisable(a6)
	moveq	#0,d0
	lea	SetTC(pc),a5
	jsr	_LVOSupervisor(a6)
	lea	GetCRP(pc),a5
	jsr	_LVOSupervisor(a6)
	move.l	d0,a0
	move.l	(a0),d0
	moveq	#-16,d1
	and.w	d1,d0
	move.l	d0,a0
loop3	move.l	(a0)+,d0
	and.w	d1,d0
	cmp.l	d5,d0
	bne.s	loop3
	add.l	d6,d5
loop4	bset	#6,-1(a0)
	move.l	(a0)+,d0
	and.w	d1,d0
	cmp.l	d5,d0
	bcs.s	loop4
skip	move.l	d7,d0
	lea	SetTC(pc),a5
	jsr	_LVOSupervisor(a6)
	jsr	_LVOEnable(a6)
	jsr	_LVOCacheClearU(a6)
	bra.s	Quit0

	opt	p=68030

GetTC	clr.l	-(sp)
	pmove.l	tc,(sp)
	move.l	(sp)+,d0
	rte

GetCRP	subq.w	#8,sp
	pmove.d	crp,(sp)
	addq.w	#4,sp
	move.l	(sp)+,d0
	rte

SetTC	move.l	d0,-(sp)
	pmove.l	(sp),tc
	pflusha
	addq.w	#4,sp
	rte

Products	dc.l	513,103	; A2386-SX
	dc.l	513,1	; A2086, A2286

TC_REGs	dc.l	$80F17324	; CPU-Control
	dc.l	$80F17540 ; C= CPU
	dc.l	$80F08630 ; A3000
	dc.l	$80F0D400 ; SoftBoot

	dc.b	"$VER: PCInhibit030 1.0 (17.4.95)",0

expname	dc.b	"expansion.library",0

	end
