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); }
static void WDEBUG_INIT(void) { isa_outb(0x3f8+3, 0x83); /* DLAB + 8N1 */ isa_outb(0x3f8+0, (115200 / 9600) & 0xFF); isa_outb(0x3f8+1, (115200 / 9600) >> 8); isa_outb(0x3f8+3, 0x03); /* 8N1 */ isa_outb(0x3f8+4, 0x03); /* RTS+DTR */ isa_outb(0x3f8+2, 0x01); /* FIFO_ENABLE */ }
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]); }
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; }
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; }
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; }
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); }
static void WDEBUG(char c) { isa_outb(0x3f8, c); }