**
** $Header: SRC:CVSROOT/Vector/ParNet/pio_wakeup.asm,v 1.1.1.1 1994/06/23 02:39:40 Barnard Exp $
**

**
** This code was originally written by Matthew Dillon and put into Public Domain
**
** All changes concerning the adaption of Matt's original code to the
** Vector Connection I/O board are © 1991-1994 by Henning Schmiedehausen
** All rights for this changes are reserved. The original code is Public Domain
**
** This code is distributed with the expressed written permission of Matthew
** Dillon (Thank you very much, Matt)
**
**

		;   WAKEUP.ASM
		;

		INCLUDE "exec/types.i"
		INCLUDE "exec/execbase.i"
		INCLUDE "exec/io.i"
		INCLUDE "vector/vectorpar.i"

		section __MERGED,DATA

		xdef	_VTask
		xdef	_VMask

		xref	_PIOBase
		xref	_UnitBase
		xref	PIOIntBit

_VTask		dc.l	0
_VMask		dc.l	0


		;   ICR interrupt

		section text,code

		xref	_SysBase
		xref	_LVOSignal

		xdef	_PioInt
		xdef	_ClearPIOInt
		xdef	_SetPIOInt

_PioInt:	movem.l	d1-d7/a0-a6,-(a7)

		move.l	_PIOBase,a1
		move.b	PIO_PSR(a1),d0
		btst.l	#PIOIntBit,d0
		bne.s	.isMine

		movem.l	(a7)+,d1-d7/a0-a6
		moveq	#0,d0
		rts

.isMine		jsr	_ClearPIOInt

		move.l	_SysBase,A6
		move.l	_VTask,A1
		move.l	_VMask,D0
		jsr	_LVOSignal(A6)

;		movea.l #LED,a1			; test-toggle power LED
;		move.b	(a1),d0
;		bchg	#1,d0
;		move.b	d0,(a1)

		movem.l	(sp)+,d1-d7/a0-a6	; restore registers
		moveq.l #1,D0		; clear interrupt.
		rts

_ClearPIOInt:	move.l	_UnitBase,a1
		bclr.b	#1,PIOR_PCR(a1)		; Interrupts sperren

		move.l	_PIOBase,a1
		moveq	#0,d0
		bset.l	#PIOIntBit,d0
		move.b	d0,PIO_PSR(a1)		; Interrupt löschen

		rts

_SetPIOInt:	move.l	_UnitBase,a1
		bset.b	#1,PIOR_PCR(a1)		; Interrupts freigeben

		rts

		END




