
#include <dev/isa/isareg.h>
#include <dev/ic/i8253reg.h>
#include <dev/isa/pcppireg.h>

NENTRY(dobeep)
	movl	$(TIMER_SEL2 | TIMER_16BIT | TIMER_SQWAVE), %eax
	outb	%al, $(IO_TIMER1 + TIMER_MODE)
	movl	$(TIMER_DIV(4000)), %eax
	outb	%al, $(IO_TIMER1 + TIMER_CNTR2)
	movb	%ah, %al
	outb	%al, $(IO_TIMER1 + TIMER_CNTR2)
	inb	$IO_PPI, %al
	orb	$PIT_SPKR, %al
	outb	%al, $IO_PPI
	movl	$100000000, %ecx
1:
	loop	1b
	andl	$~PIT_SPKR, %eax
	outb	%al, $IO_PPI
	movl	$500000000, %ecx
2:
	loop	2b
	ret
