Пример #1
0
int
joy_get_tick()
{
	int low, high;

	isa_outb(IO_TIMER1 + TIMER_MODE, TIMER_SEL0);
	low = isa_inb(IO_TIMER1 + TIMER_CNTR0);
	high = isa_inb(IO_TIMER1 + TIMER_CNTR0);

	return (high << 8) | low;
}
Пример #2
0
void
sysbeep(int pitch, int period)
{
	static callout_t sysbeep_ch;
	static int last_pitch;
	static bool again;
	int s;

	if (!again) {
		callout_init(&sysbeep_ch, 0);
		again = true;
	}

	if (beeping)
		callout_stop(&sysbeep_ch);
	if (pitch == 0 || period == 0) {
		sysbeepstop(0);
		last_pitch = 0;
		return;
	}
	if (!beeping || last_pitch != pitch) {
		s = splhigh();	/* FIXME */
		isa_outb(IO_TIMER1 + TIMER_MODE,
			 TIMER_SEL2 | TIMER_16BIT | TIMER_SQWAVE);
		isa_outb(IO_TIMER1 + TIMER_CNTR2, TIMER_DIV(pitch) % 256);
		isa_outb(IO_TIMER1 + TIMER_CNTR2, TIMER_DIV(pitch) / 256);
		isa_outb(PITAUX_PORT, isa_inb(PITAUX_PORT) | PIT_SPKR);	/* enable counter 2 */
		splx(s);
	}
	last_pitch = pitch;
	beeping = 1;
	callout_reset(&sysbeep_ch, period, sysbeepstop, NULL);
}
Пример #3
0
static void
prepivr_establish_irq(struct pic_ops *pic, int irq, int type, int maxlevel)
{
	u_int8_t elcr[2];
	int icu, bit;

	icu = irq / 8;
	bit = irq % 8;
	elcr[0] = isa_inb(IO_ELCR1);
	elcr[1] = isa_inb(IO_ELCR2);

	if (type == IST_LEVEL)
		elcr[icu] |= 1 << bit;
	else
		elcr[icu] &= ~(1 << bit);

	isa_outb(IO_ELCR1, elcr[0]);
	isa_outb(IO_ELCR2, elcr[1]);
}
Пример #4
0
void
sysbeepstop(void *arg)
{
	int s;

	/* disable counter 2 */
	s = splhigh();	/* FIXME */
	isa_outb(PITAUX_PORT, isa_inb(PITAUX_PORT) & ~PIT_SPKR);
	splx(s);
	beeping = 0;
}
Пример #5
0
int
isabr_dti_intr_status(void)
{
	int isa_vector;
	char vector;

	isa_outb(IO_ICU1, 0x0f);	/* Poll */
	vector = isa_inb(IO_ICU1);
	isa_vector = vector & 7;
	if (vector > 0 || isa_vector == 2) {
		isa_outb(IO_ICU2, 0x0f);
		vector = isa_inb(IO_ICU2);
		if (vector > 0) {
			printf("isabr_dti_intr_status: spurious interrupt\n");
			return -1;
		}
		isa_vector = (vector & 7) | 8;
	}
	return isa_vector;
}
Пример #6
0
int
isabr_dti_intr_status()
{
	int isa_vector;
	char vector;

	isa_outb(IO_ICU1, 0x0f);	/* Poll */
	vector = isa_inb(IO_ICU1);
	if (vector < 0) /* XXX: OpenBSD source had a bug, re-look this */
		return (-1);
	isa_vector = vector & 7;
	if (isa_vector == 2) { 
		isa_outb(IO_ICU2, 0x0f);
		vector = isa_inb(IO_ICU2);
		if (vector > 0) {
			printf("isa: spurious interrupt.\n");
			return (-1);
		}
		isa_vector = (vector & 7) | 8;
	}
	return (isa_vector);
}