diff --git a/sys/arch/alpha/alpha/promcons.c b/sys/arch/alpha/alpha/promcons.c index 8be259a69ce1..d8064e2ecffd 100644 --- a/sys/arch/alpha/alpha/promcons.c +++ b/sys/arch/alpha/alpha/promcons.c @@ -1,4 +1,4 @@ -/* $NetBSD: promcons.c,v 1.13 1998/03/21 22:52:59 mycroft Exp $ */ +/* $NetBSD: promcons.c,v 1.14 2000/03/23 06:32:32 thorpej Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -29,7 +29,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: promcons.c,v 1.13 1998/03/21 22:52:59 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: promcons.c,v 1.14 2000/03/23 06:32:32 thorpej Exp $"); #include #include @@ -60,6 +60,8 @@ void promstart __P((struct tty *)); void promtimeout __P((void *)); int promparam __P((struct tty *, struct termios *)); +struct callout prom_ch = CALLOUT_INITIALIZER; + int promopen(dev, flag, mode, p) dev_t dev; @@ -108,7 +110,7 @@ promopen(dev, flag, mode, p) polltime = hz / PROM_POLL_HZ; if (polltime < 1) polltime = 1; - timeout(promtimeout, tp, polltime); + callout_reset(&prom_ch, polltime, promtimeout, tp); } return error; } @@ -122,7 +124,7 @@ promclose(dev, flag, mode, p) int unit = minor(dev); struct tty *tp = prom_tty[unit]; - untimeout(promtimeout, tp); + callout_stop(&prom_ch); (*linesw[tp->t_line].l_close)(tp, flag); ttyclose(tp); return 0; @@ -232,7 +234,7 @@ promtimeout(v) if (tp->t_state & TS_ISOPEN) (*linesw[tp->t_line].l_rint)(c, tp); } - timeout(promtimeout, tp, polltime); + callout_reset(&prom_ch, polltime, promtimeout, tp); } struct tty * diff --git a/sys/arch/alpha/isa/fd.c b/sys/arch/alpha/isa/fd.c index ac930e74b231..5e32aa8b8f31 100644 --- a/sys/arch/alpha/isa/fd.c +++ b/sys/arch/alpha/isa/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.8 2000/02/07 22:07:28 thorpej Exp $ */ +/* $NetBSD: fd.c,v 1.9 2000/03/23 06:32:33 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -96,6 +96,7 @@ #include #include +#include #include #include #include @@ -165,6 +166,9 @@ struct fdc_softc { bus_space_handle_t sc_ioh; /* ISA io handle */ isa_chipset_tag_t sc_ic; /* ISA chipset info */ + struct callout sc_timo_ch; /* timeout callout */ + struct callout sc_intr_ch; /* pseudo-intr callout */ + /* * XXX We have port overlap with the first IDE controller. * Until we have a reasonable solution for handling overlap @@ -238,6 +242,8 @@ struct fd_softc { struct fd_type *sc_type; /* current type descriptor */ struct fd_type sc_type_copy; /* copy for fiddling when formatting */ + struct callout sc_motor_ch; + daddr_t sc_blkno; /* starting block number */ int sc_bcount; /* byte count left */ int sc_opts; /* user-set options */ @@ -432,6 +438,9 @@ fdcattach(parent, self, aux) printf("\n"); + callout_init(&fdc->sc_timo_ch); + callout_init(&fdc->sc_intr_ch); + /* Re-map the I/O space. */ if (bus_space_map(iot, ia->ia_iobase, 6 /* XXX FDC_NPORT */, 0, &ioh)) { printf("%s: can't map i/o space\n", fdc->sc_dev.dv_xname); @@ -545,6 +554,8 @@ fdattach(parent, self, aux) struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + callout_init(&fd->sc_motor_ch); + /* XXX Allow `flags' to override device type? */ if (type) @@ -640,7 +651,7 @@ fdstrategy(bp) /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort_cylinder(&fd->sc_q, bp); - untimeout(fd_motor_off, fd); /* a good idea */ + callout_stop(&fd->sc_motor_ch); /* a good idea */ if (fd->sc_active == 0) fdstart(fd); #ifdef DIAGNOSTIC @@ -710,7 +721,7 @@ fdfinish(fd, bp) biodone(bp); /* turn off motor 5s from now */ - timeout(fd_motor_off, fd, 5 * hz); + timeout(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; } @@ -1013,7 +1024,7 @@ loop: fd->sc_skip = 0; fd->sc_bcount = bp->b_bcount; fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); - untimeout(fd_motor_off, fd); + callout_stop(&fd->sc_motor_ch); if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { fdc->sc_state = MOTORWAIT; return 1; @@ -1022,14 +1033,15 @@ loop: /* Turn on the motor, being careful about pairing. */ struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; if (ofd && ofd->sc_flags & FD_MOTOR) { - untimeout(fd_motor_off, ofd); + callout_stop(&ofd->sc_motor_ch); ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); } fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; fd_set_motor(fdc, 0); fdc->sc_state = MOTORWAIT; /* Allow .25s for motor to stabilize. */ - timeout(fd_motor_on, fd, hz / 4); + callout_reset(&fd->fd_motor_ch, hz / 4, + fd_motor_on, fd); return 1; } /* Make sure the right drive is selected. */ @@ -1055,7 +1067,7 @@ loop: fd->sc_dk.dk_seek++; disk_busy(&fd->sc_dk); - timeout(fdctimeout, fdc, 4 * hz); + callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc); return 1; case DOIO: @@ -1128,14 +1140,14 @@ loop: disk_busy(&fd->sc_dk); /* allow 2 seconds for operation */ - timeout(fdctimeout, fdc, 2 * hz); + callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc); return 1; /* will return later */ case SEEKWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = SEEKCOMPLETE; /* allow 1/50 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 50); + callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc); return 1; case SEEKCOMPLETE: @@ -1163,7 +1175,7 @@ loop: goto loop; case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid)); @@ -1201,11 +1213,11 @@ loop: delay(100); fd_set_motor(fdc, 0); fdc->sc_state = RESETCOMPLETE; - timeout(fdctimeout, fdc, hz / 2); + callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc); return 1; /* will return later */ case RESETCOMPLETE: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); /* clear the controller output buffer */ for (i = 0; i < 4; i++) { out_fdc(iot, ioh, NE7CMD_SENSEI); @@ -1217,14 +1229,14 @@ loop: out_fdc(iot, ioh, NE7CMD_RECAL); /* recalibrate function */ out_fdc(iot, ioh, fd->sc_drive); fdc->sc_state = RECALWAIT; - timeout(fdctimeout, fdc, 5 * hz); + callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc); return 1; /* will return later */ case RECALWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = RECALCOMPLETE; /* allow 1/30 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 30); + callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc); return 1; /* will return later */ case RECALCOMPLETE: diff --git a/sys/arch/amiga/amiga/machdep.c b/sys/arch/amiga/amiga/machdep.c index 7729c104ef78..7f3471a42b41 100644 --- a/sys/arch/amiga/amiga/machdep.c +++ b/sys/arch/amiga/amiga/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.147 2000/02/21 20:38:46 erh Exp $ */ +/* $NetBSD: machdep.c,v 1.148 2000/03/23 06:33:08 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -1559,6 +1560,7 @@ int panicbutton = 1; /* non-zero if panic buttons are enabled */ int crashandburn = 0; int candbdelay = 50; /* give em half a second */ void candbtimer __P((void)); +struct callout candbtimer_ch = CALLOUT_INITIALIZER; void candbtimer() @@ -1594,7 +1596,8 @@ nmihand(frame) "forced crash, nosync" : "forced crash"); } crashandburn++; - timeout(candbtimer, (caddr_t)0, candbdelay); + callout_reset(&candbtimer_ch, candbdelay, + candbtimer, NULL); } #endif return; diff --git a/sys/arch/amiga/dev/fd.c b/sys/arch/amiga/dev/fd.c index 44a2b5cc3e26..e69866dcb554 100644 --- a/sys/arch/amiga/dev/fd.c +++ b/sys/arch/amiga/dev/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.44 2000/03/16 16:37:20 kleink Exp $ */ +/* $NetBSD: fd.c,v 1.45 2000/03/23 06:33:10 thorpej Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -33,6 +33,7 @@ */ #include #include +#include #include #include #include @@ -143,6 +144,8 @@ struct fd_softc { struct disk dkdev; /* generic disk info */ struct buf_queue bufq; /* queue pending I/O operations */ struct buf curbuf; /* state of current I/O operation */ + struct callout calibrate_ch; + struct callout motor_ch; struct fdtype *type; void *cachep; /* cached track data (write through) */ int cachetrk; /* cahced track -1 for none */ @@ -389,6 +392,8 @@ fdattach(pdp, dp, auxp) sc = (struct fd_softc *)dp; BUFQ_INIT(&sc->bufq); + callout_init(&sc->calibrate_ch); + callout_init(&sc->motor_ch); sc->curcyl = sc->cachetrk = -1; sc->openpart = -1; @@ -1468,11 +1473,11 @@ fdcalibrate(arg) * trk++, trk, trk++, trk, trk++, trk, trk++, trk and dma */ if (loopcnt < 8) - timeout(fdcalibrate, sc, hz / 8); + callout_reset(&sc->calibrate_ch, hz / 8, fdcalibrate, sc); else { loopcnt = 0; fdc_indma = NULL; - timeout(fdmotoroff, sc, 3 * hz / 2); + callout_reset(&sc->motor_ch, 3 * hz / 2, fdmotoroff, sc); fddmastart(sc, sc->cachetrk); } } @@ -1486,7 +1491,7 @@ fddmadone(sc, timeo) printf("fddmadone: unit %d, timeo %d\n", sc->hwunit, timeo); #endif fdc_indma = NULL; - untimeout(fdmotoroff, sc); + callout_stop(&sc->motor_ch); FDDMASTOP; /* @@ -1502,7 +1507,7 @@ fddmadone(sc, timeo) /* * motor runs for 1.5 seconds after last dma */ - timeout(fdmotoroff, sc, 3 * hz / 2); + callout_reset(&sc->motor_ch, 3 * hz / 2, fdmotoroff, sc); } if (sc->flags & FDF_DIRTY) { /* @@ -1550,7 +1555,7 @@ fddmadone(sc, timeo) /* * this will be restarted at end of calibrate loop. */ - untimeout(fdmotoroff, sc); + callout_stop(&sc->motor_ch); fdcalibrate(sc); return; } diff --git a/sys/arch/amiga/dev/ite.c b/sys/arch/amiga/dev/ite.c index f4d2a2dff04e..5a563fdbae5f 100644 --- a/sys/arch/amiga/dev/ite.c +++ b/sys/arch/amiga/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.51 1998/07/04 22:18:16 jonathan Exp $ */ +/* $NetBSD: ite.c,v 1.52 2000/03/23 06:33:11 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -652,7 +653,7 @@ itestart(tp) /* we have characters remaining. */ if (rbp->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } /* wakeup we are below */ if (rbp->c_cc <= tp->t_lowat) { @@ -866,6 +867,8 @@ ite_cnfilter(c, caller) static u_char last_char; static u_char tout_pending; +static struct callout repeat_ch = CALLOUT_INITIALIZER; + /*ARGSUSED*/ static void repeat_handler(arg) @@ -919,7 +922,7 @@ ite_filter(c, caller) /* stop repeating on up event */ if (up) { if (tout_pending) { - untimeout(repeat_handler, 0); + callout_stop(&repeat_ch); tout_pending = 0; last_char = 0; } @@ -927,7 +930,7 @@ ite_filter(c, caller) return; } else if (tout_pending && last_char != c) { /* different character, stop also */ - untimeout(repeat_handler, 0); + callout_stop(&repeat_ch); tout_pending = 0; last_char = 0; } @@ -970,12 +973,14 @@ ite_filter(c, caller) if (!tout_pending && caller == ITEFILT_TTY && kbd_ite->key_repeat) { tout_pending = 1; last_char = c; - timeout(repeat_handler, 0, start_repeat_timeo * hz / 100); + callout_reset(&repeat_ch, + start_repeat_timeo * hz / 100, repeat_handler, NULL); } else if (!tout_pending && caller == ITEFILT_REPEATER && kbd_ite->key_repeat) { tout_pending = 1; last_char = c; - timeout(repeat_handler, 0, next_repeat_timeo * hz / 100); + callout_reset(&repeat_ch, + next_repeat_timeo * hz / 100, repeat_handler, NULL); } /* handle dead keys */ if (key.mode & KBD_MODE_DEAD) { diff --git a/sys/arch/amiga/dev/ms.c b/sys/arch/amiga/dev/ms.c index 7a6788e61684..f778ed9fa788 100644 --- a/sys/arch/amiga/dev/ms.c +++ b/sys/arch/amiga/dev/ms.c @@ -1,4 +1,4 @@ -/* $NetBSD: ms.c,v 1.15 1998/01/12 10:40:04 thorpej Exp $ */ +/* $NetBSD: ms.c,v 1.16 2000/03/23 06:33:11 thorpej Exp $ */ /* * based on: @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,8 @@ void ms_disable __P((dev_t)); struct ms_softc { struct device sc_dev; + struct callout sc_intr_ch; + u_char ms_horc; /* horizontal counter on last scan */ u_char ms_verc; /* vertical counter on last scan */ char ms_mb; /* mouse button state */ @@ -117,7 +120,10 @@ msattach(pdp, dp, auxp) struct device *pdp, *dp; void *auxp; { + struct ms_softc *sc = (void *) dp; + printf("\n"); + callout_init(&sc->sc_intr_ch); } /* @@ -146,7 +152,7 @@ ms_enable(dev) */ ms->ms_ready = 1; - timeout(msintr, (void *)minor(dev), 2); + callout_reset(&ms->sc_intr_ch, 2, msintr, ms); } /* @@ -180,15 +186,14 @@ msintr(arg) { static const char to_one[] = { 1, 2, 2, 4, 4, 4, 4 }; static const int to_id[] = { MS_RIGHT, MS_MIDDLE, 0, MS_LEFT }; - struct ms_softc *ms; + struct ms_softc *ms = arg; struct firm_event *fe; int mb, ub, d, get, put, any, unit; u_char pra, *horc, *verc; u_short pot, count; short dx, dy; - unit = (int)arg; - ms = (struct ms_softc *)getsoftc(ms_cd, unit); + unit = ms->sc_dev.dv_unit; horc = ((u_char *) &count) + 1; verc = (u_char *) &count; @@ -326,7 +331,7 @@ out: * handshake with ms_disable */ if (ms->ms_ready) - timeout(msintr, (void *)unit, 2); + callout_reset(&ms->sc_intr_ch, 2, msintr, ms); else wakeup(ms); } diff --git a/sys/arch/amiga/dev/par.c b/sys/arch/amiga/dev/par.c index 1f57049d1bb1..dda52c89226f 100644 --- a/sys/arch/amiga/dev/par.c +++ b/sys/arch/amiga/dev/par.c @@ -1,4 +1,4 @@ -/* $NetBSD: par.c,v 1.19 2000/03/16 16:37:20 kleink Exp $ */ +/* $NetBSD: par.c,v 1.20 2000/03/23 06:33:12 thorpej Exp $ */ /* * Copyright (c) 1982, 1990 The Regents of the University of California. @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -64,10 +65,15 @@ struct par_softc { #define sc_burst sc_param.burst #define sc_timo sc_param.timo #define sc_delay sc_param.delay + + struct callout sc_timo_ch; + struct callout sc_start_ch; } *par_softcp; #define getparsp(x) (x > 0 ? NULL : par_softcp) +struct callout parintr_ch = CALLOUT_INITIALIZER; + /* sc_flags values */ #define PARF_ALIVE 0x01 #define PARF_OPEN 0x02 @@ -133,6 +139,9 @@ parattach(pdp, dp, auxp) #endif par_softcp->sc_flags = PARF_ALIVE; printf("\n"); + + callout_init(&par_softcp->sc_timo_ch); + callout_init(&par_softcp->sc_start_ch); } int @@ -201,14 +210,11 @@ void parstart(arg) void *arg; { - struct par_softc *sc; - int unit; + struct par_softc *sc = arg; - unit = (int)arg; - sc = getparsp(unit); #ifdef DEBUG if (pardebug & PDB_FOLLOW) - printf("parstart(%x)\n", unit); + printf("parstart(%x)\n", sc->sc_dev.dv_unit); #endif sc->sc_flags &= ~PARF_DELAY; wakeup(sc); @@ -218,14 +224,11 @@ void partimo(arg) void *arg; { - struct par_softc *sc; - int unit; + struct par_softc *sc = arg; - unit = (int) arg; - sc = getparsp(unit); #ifdef DEBUG if (pardebug & PDB_FOLLOW) - printf("partimo(%x)\n", unit); + printf("partimo(%x)\n", sc->sc_dev.dv_unit); #endif sc->sc_flags &= ~(PARF_UIO|PARF_TIMO); wakeup(sc); @@ -294,7 +297,7 @@ parrw(dev, uio) if (sc->sc_timo > 0) { sc->sc_flags |= PARF_TIMO; - timeout(partimo, (void *)unit, sc->sc_timo); + callout_reset(&sc->sc_timo_ch, sc->sc_timo, partimo, sc); } while (uio->uio_resid > 0) { @@ -325,7 +328,7 @@ again: #endif if (sc->sc_flags & PARF_TIMO) { - untimeout(partimo, (void *)unit); + callout_stop(&sc->sc_timo_ch); sc->sc_flags &= ~PARF_TIMO; } splx(s); @@ -391,7 +394,7 @@ again: if (sc->sc_delay > 0) { sc->sc_flags |= PARF_DELAY; - timeout(parstart, (void *)unit, sc->sc_delay); + callout_reset(&sc->sc_start_ch, sc->sc_delay, parstart, sc); error = tsleep(sc, PCATCH | (PZERO - 1), "par-cdelay", 0); if (error) { @@ -415,12 +418,12 @@ again: s = splsoftclock(); if (sc->sc_flags & PARF_TIMO) { - untimeout(partimo, (void *)unit); + callout_stop(&sc->sc_timo_ch); sc->sc_flags &= ~PARF_TIMO; } if (sc->sc_flags & PARF_DELAY) { - untimeout(parstart, (void *)unit); + callout_stop(&sc->sc_start_ch); sc->sc_flags &= ~PARF_DELAY; } splx(s); @@ -536,7 +539,7 @@ parintr(arg) */ if (mask) { if (partimeout_pending) - untimeout(parintr, 0); + callout_stop(&parintr_ch); if (parsend_pending) parsend_pending = 0; } @@ -572,7 +575,7 @@ parsendch (ch) & (CIAB_PRA_SEL|CIAB_PRA_BUSY|CIAB_PRA_POUT))); #endif /* wait a second, and try again */ - timeout(parintr, 0, hz); + callout_reset(&parintr_ch, hz, parintr, NULL); partimeout_pending = 1; /* this is essentially a flipflop to have us wait for the first character being transmitted when trying to transmit @@ -588,7 +591,7 @@ parsendch (ch) printf ("parsendch interrupted, error = %d\n", error); #endif if (partimeout_pending) - untimeout(parintr, 0); + callout_stop(&parintr_ch); partimeout_pending = 0; } diff --git a/sys/arch/amiga/dev/sbic.c b/sys/arch/amiga/dev/sbic.c index d1217bf050de..5d1468e546df 100644 --- a/sys/arch/amiga/dev/sbic.c +++ b/sys/arch/amiga/dev/sbic.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbic.c,v 1.38 2000/01/18 19:33:32 thorpej Exp $ */ +/* $NetBSD: sbic.c,v 1.39 2000/03/23 06:33:12 thorpej Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -846,6 +846,7 @@ sbicinit(dev) TAILQ_INIT(&dev->ready_list); TAILQ_INIT(&dev->nexus_list); TAILQ_INIT(&dev->free_list); + callout_init(&dev->sc_timo_ch); dev->sc_nexus = NULL; dev->sc_xs = NULL; acb = dev->sc_acb; @@ -857,7 +858,8 @@ sbicinit(dev) bzero(dev->sc_tinfo, sizeof(dev->sc_tinfo)); #ifdef DEBUG /* make sure timeout is really not needed */ - timeout((void *)sbictimeout, dev, 30 * hz); + callout_reset(&dev->sc_timo_ch, 30 * hz, + (void *)sbictimeout, dev); #endif } else panic("sbic: reinitializing driver!"); @@ -2712,7 +2714,8 @@ sbictimeout(dev) dev->sc_dmatimo++; } splx(s); - timeout((void *)sbictimeout, dev, 30 * hz); + callout_reset(&dev->sc_timo_ch, 30 * hz, + (void *)sbictimeout, dev); } void diff --git a/sys/arch/amiga/dev/sbicvar.h b/sys/arch/amiga/dev/sbicvar.h index 736689b9e2ac..c6595f66ff34 100644 --- a/sys/arch/amiga/dev/sbicvar.h +++ b/sys/arch/amiga/dev/sbicvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sbicvar.h,v 1.14 1998/11/19 21:44:37 thorpej Exp $ */ +/* $NetBSD: sbicvar.h,v 1.15 2000/03/23 06:33:13 thorpej Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -40,6 +40,7 @@ #ifndef _SBICVAR_H_ #define _SBICVAR_H_ #include +#include /* * The largest single request will be MAXPHYS bytes which will require @@ -105,6 +106,7 @@ struct sbic_tinfo { struct sbic_softc { struct device sc_dev; struct isr sc_isr; + struct callout sc_timo_ch; struct target_sync { u_char state; u_char period; diff --git a/sys/arch/arc/dev/fd.c b/sys/arch/arc/dev/fd.c index 5af10ec08899..ed24a468f057 100644 --- a/sys/arch/arc/dev/fd.c +++ b/sys/arch/arc/dev/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.17 2000/02/22 11:26:00 soda Exp $ */ +/* $NetBSD: fd.c,v 1.18 2000/03/23 06:34:23 thorpej Exp $ */ /* $OpenBSD: fd.c,v 1.6 1998/10/03 21:18:57 millert Exp $ */ /* NetBSD: fd.c,v 1.78 1995/07/04 07:23:09 mycroft Exp */ @@ -78,6 +78,7 @@ #include #include +#include #include #include #include @@ -131,6 +132,9 @@ enum fdc_state { struct fdc_softc { struct device sc_dev; /* boilerplate */ + struct callout sc_timo_ch; /* timeout callout */ + struct callout sc_intr_ch; /* pseudo-intr callout */ + struct dma_softc __dma; struct dma_softc *dma; @@ -190,6 +194,8 @@ struct fd_softc { struct fd_type *sc_deftype; /* default type descriptor */ struct fd_type *sc_type; /* current type descriptor */ + struct callout sc_motor_ch; + daddr_t sc_blkno; /* starting block number */ int sc_bcount; /* byte count left */ int sc_skip; /* bytes already transferred */ @@ -321,6 +327,9 @@ fdcattach(parent, self, aux) printf("\n"); + callout_init(&fdc->sc_timo_ch); + callout_init(&fdc->sc_intr_ch); + BUS_INTR_ESTABLISH(ca, fdcintr, fdc); /* @@ -397,6 +406,8 @@ fdattach(parent, self, aux) struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + callout_init(&fd->sc_motor_ch); + /* XXX Allow `flags' to override device type? */ if (type) @@ -507,7 +518,7 @@ fdstrategy(bp) /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort_cylinder(&fd->sc_q, bp); - untimeout(fd_motor_off, fd); /* a good idea */ + callout_stop(&fd->sc_motor_ch); /* a good idea */ if (fd->sc_active == 0) fdstart(fd); #ifdef DIAGNOSTIC @@ -571,7 +582,7 @@ fdfinish(fd, bp) BUFQ_REMOVE(&fd->sc_q, bp); biodone(bp); /* turn off motor 5s from now */ - timeout(fd_motor_off, fd, 10 * hz); + callout_reset(&fd->sc_motor_ch, 10 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; } @@ -861,7 +872,7 @@ loop: fd->sc_skip = 0; fd->sc_bcount = bp->b_bcount; fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); - untimeout(fd_motor_off, fd); + callout_stop(&fd->fd_motor_ch); if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { fdc->sc_state = MOTORWAIT; return 1; @@ -870,14 +881,15 @@ loop: /* Turn on the motor, being careful about pairing. */ struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; if (ofd && ofd->sc_flags & FD_MOTOR) { - untimeout(fd_motor_off, ofd); + callout_stop(&ofd->fd_motor_ch); ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); } fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; fd_set_motor(fdc, 0); fdc->sc_state = MOTORWAIT; /* Allow .5s for motor to stabilize. */ - timeout(fd_motor_on, fd, hz / 2); + callout_reset(&fd->sc_motor_ch, hz / 2, + fd_motor_on, fd); return 1; } /* Make sure the right drive is selected. */ @@ -899,7 +911,7 @@ loop: fd->sc_cylin = -1; fdc->sc_state = SEEKWAIT; - timeout(fdctimeout, fdc, 4 * hz); + callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc); return 1; case DOIO: @@ -947,14 +959,15 @@ loop: out_fdc(iobase, type->datalen); /* data length */ fdc->sc_state = IOCOMPLETE; /* allow 2 seconds for operation */ - timeout(fdctimeout, fdc, 2 * hz); + callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc); return 1; /* will return later */ case SEEKWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = SEEKCOMPLETE; /* allow 1/50 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 50); + callout_reset(&fdc->sc_intr_ch, hz / 50, + fdcpseudointr, fdc); return 1; case SEEKCOMPLETE: @@ -981,7 +994,7 @@ loop: goto loop; case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); if (fdcresult(fdc) != 7 || (st0 & 0xf8) != 0) { DMA_RESET(fdc->dma); #ifdef FD_DEBUG @@ -1017,11 +1030,11 @@ loop: delay(100); fd_set_motor(fdc, 0); fdc->sc_state = RESETCOMPLETE; - timeout(fdctimeout, fdc, hz / 2); + callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc); return 1; /* will return later */ case RESETCOMPLETE: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); /* clear the controller output buffer */ for (i = 0; i < 4; i++) { out_fdc(iobase, NE7CMD_SENSEI); @@ -1033,14 +1046,15 @@ loop: out_fdc(iobase, NE7CMD_RECAL); /* recalibrate function */ out_fdc(iobase, fd->sc_drive); fdc->sc_state = RECALWAIT; - timeout(fdctimeout, fdc, 5 * hz); + callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc); return 1; /* will return later */ case RECALWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = RECALCOMPLETE; /* allow 1/30 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 30); + callout_reset(&fdc->sc_intr_ch, hz / 30, + fdcpseudointr, fdc); return 1; /* will return later */ case RECALCOMPLETE: diff --git a/sys/arch/arc/dev/pccons.c b/sys/arch/arc/dev/pccons.c index 78526832960b..874bfb75d7f1 100644 --- a/sys/arch/arc/dev/pccons.c +++ b/sys/arch/arc/dev/pccons.c @@ -1,4 +1,4 @@ -/* $NetBSD: pccons.c,v 1.16 2000/03/06 21:36:06 thorpej Exp $ */ +/* $NetBSD: pccons.c,v 1.17 2000/03/23 06:34:24 thorpej Exp $ */ /* $OpenBSD: pccons.c,v 1.22 1999/01/30 22:39:37 imp Exp $ */ /* NetBSD: pccons.c,v 1.89 1995/05/04 19:35:20 cgd Exp */ /* NetBSD: pms.c,v 1.21 1995/04/18 02:25:18 mycroft Exp */ @@ -154,6 +154,8 @@ struct opms_softc { /* driver status information */ int sc_x, sc_y; /* accumulated motion in the X,Y axis */ }; +static struct callout async_update_ch = CALLOUT_INITIALIZER; + int pcprobe __P((struct device *, struct cfdata *, void *)); void pcattach __P((struct device *, struct device *, void *)); int pcintr __P((void *)); @@ -464,13 +466,14 @@ async_update() if (kernel || polling) { if (async) - untimeout((void(*)(void *))do_async_update, NULL); + callout_stop(&async_update_ch); do_async_update(1); } else { if (async) return; async = 1; - timeout((void(*)(void *))do_async_update, NULL, 1); + callout_reset(&async_update_ch, 1, + (void(*)(void *))do_async_update, NULL); } } @@ -820,7 +823,7 @@ pcstart(tp) tp->t_state &= ~TS_BUSY; if (cl->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } if (cl->c_cc <= tp->t_lowat) { if (tp->t_state & TS_ASLEEP) { diff --git a/sys/arch/arc/dti/btl.c b/sys/arch/arc/dti/btl.c index 73f0f097937e..52e0d93bf81c 100644 --- a/sys/arch/arc/dti/btl.c +++ b/sys/arch/arc/dti/btl.c @@ -1,4 +1,4 @@ -/* $NetBSD: btl.c,v 1.3 2000/02/22 11:26:01 soda Exp $ */ +/* $NetBSD: btl.c,v 1.4 2000/03/23 06:34:25 thorpej Exp $ */ #undef BTDIAG #define integrate @@ -503,7 +503,7 @@ AGAIN: goto next; } - untimeout(bt_timeout, ccb); + callout_stop(&ccb->xs->xs_callout); bt_done(sc, ccb); next: @@ -812,7 +812,8 @@ bt_start_ccbs(sc) isa_outb(iobase + BT_CMD_PORT, BT_START_SCSI); if ((ccb->xs->xs_control & XS_CTL_POLL) == 0) - timeout(bt_timeout, ccb, (ccb->timeout * hz) / 1000); + callout_reset(&ccb->xs->xs_callout, + (ccb->timeout * hz) / 1000, bt_timeout, ccb); ++sc->sc_mbofull; bt_nextmbx(wmbo, wmbx, mbo); diff --git a/sys/arch/arc/isa/isabus.c b/sys/arch/arc/isa/isabus.c index 8fe99a0259bc..28abda21665e 100644 --- a/sys/arch/arc/isa/isabus.c +++ b/sys/arch/arc/isa/isabus.c @@ -1,4 +1,4 @@ -/* $NetBSD: isabus.c,v 1.7 2000/03/03 12:50:21 soda Exp $ */ +/* $NetBSD: isabus.c,v 1.8 2000/03/23 06:34:25 thorpej Exp $ */ /* $OpenBSD: isabus.c,v 1.15 1998/03/16 09:38:46 pefo Exp $ */ /* NetBSD: isa.c,v 1.33 1995/06/28 04:30:51 cgd Exp */ @@ -92,6 +92,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include @@ -114,6 +115,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include static int beeping; +static struct callout sysbeep_ch = CALLOUT_INITIALIZER; #define IRQ_SLAVE 2 #define ICU_LEN 16 @@ -523,7 +525,7 @@ sysbeep(pitch, period) return; /* Can't beep yet. */ if (beeping) - untimeout(sysbeepstop, 0); + callout_stop(&sysbeep_ch); if (!beeping || last_pitch != pitch) { s = splhigh(); isa_outb(IO_TIMER1 + TIMER_MODE, @@ -535,5 +537,5 @@ sysbeep(pitch, period) } last_pitch = pitch; beeping = last_period = period; - timeout(sysbeepstop, 0, period); + callout_reset(&sysbeep_ch, period, sysbeepstop, NULL); } diff --git a/sys/arch/arm32/dev/kbd.c b/sys/arch/arm32/dev/kbd.c index b513fe3719a1..289d3280c455 100644 --- a/sys/arch/arm32/dev/kbd.c +++ b/sys/arch/arm32/dev/kbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: kbd.c,v 1.24 1999/02/02 04:02:26 mark Exp $ */ +/* $NetBSD: kbd.c,v 1.25 2000/03/23 06:35:14 thorpej Exp $ */ /* * Copyright (c) 1994-1997 Mark Brinicombe. @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -110,6 +111,8 @@ static int rawkbd_device = 0; int modifiers = 0; static int kbd_ack = 0; static int kbd_resend = 0; +static struct callout autorepeat_ch = CALLOUT_INITIALIZER; +static struct callout autorepeatstart_ch = CALLOUT_INITIALIZER; #ifdef PMAP_DEBUG extern int pmap_debug_level; @@ -232,8 +235,8 @@ kbdopen(dev, flag, mode, p) /* Kill any active autorepeat */ - untimeout(autorepeatstart, &autorepeatkey); - untimeout(autorepeat, &autorepeatkey); + callout_stop(&autorepeatstart_ch); + callout_stop(&autorepeat_ch); return(0); } @@ -921,8 +924,8 @@ kbddecodekey(sc, code) if (!up && key != 0) { if (key >= 0x200) { - untimeout(autorepeatstart, &autorepeatkey); - untimeout(autorepeat, &autorepeatkey); + callout_stop(&autorepeatstart_ch); + callout_stop(&autorepeat_ch); autorepeatkey = -1; #if (NVT > 0) if ((key & ~0x0f) == 0x480) @@ -999,18 +1002,20 @@ kbddecodekey(sc, code) */ if (rawkbd_device == 0 && physconkbd(key) == 0) { if (autorepeatkey != key) { - untimeout(autorepeatstart, &autorepeatkey); - untimeout(autorepeat, &autorepeatkey); + callout_stop(&autorepeatstart_ch); + callout_stop(&autorepeat_ch); autorepeatkey = key; - timeout(autorepeatstart, &autorepeatkey, hz/kbdautorepeat.ka_delay); + callout_reset(&autorepeatstart_ch, + hz / kbdautorepeat.ka_delay, + autorepeatstart, &autorepeatkey); } } return(1); } } else { - untimeout(autorepeatstart, &autorepeatkey); - untimeout(autorepeat, &autorepeatkey); + callout_stop(&autorepeatstart_ch); + callout_stop(&autorepeat_ch); autorepeatkey = -1; } return(0); @@ -1022,7 +1027,8 @@ autorepeatstart(key) void *key; { physconkbd(*((int *)key)); - timeout(autorepeat, key, hz/kbdautorepeat.ka_rate); + callout_reset(&autorepeat_ch, hz / kbdautorepeat.ka_rate, + autorepeat, key); } @@ -1031,7 +1037,8 @@ autorepeat(key) void *key; { physconkbd(*((int *)key)); - timeout(autorepeat, key, hz/kbdautorepeat.ka_rate); + callout_reset(&autorepeat_ch, hz / kbdautorepeat.ka_rate, + autorepeat, key); } /* End of kbd.c */ diff --git a/sys/arch/arm32/dev/pms.c b/sys/arch/arm32/dev/pms.c index 6b13a0b6a761..cde9e5de7adb 100644 --- a/sys/arch/arm32/dev/pms.c +++ b/sys/arch/arm32/dev/pms.c @@ -1,4 +1,4 @@ -/* $NetBSD: pms.c,v 1.20 1999/06/01 09:34:07 mark Exp $ */ +/* $NetBSD: pms.c,v 1.21 2000/03/23 06:35:14 thorpej Exp $ */ /*- * Copyright (c) 1996 D.C. Tsen @@ -190,6 +190,7 @@ pmsinit(sc) int mid; /* Set up softc */ + callout_init(&sc->sc_watchdog_ch); sc->sc_state = 0; sc->origx = 0; sc->origy = 0; @@ -295,7 +296,8 @@ pmsopen(dev, flag, mode, p) sc->sc_intenable(sc, 1); /* install watchdog timeout */ - timeout(pmswatchdog, (void *) sc, 30 * hz); + callout_reset(&sc->sc_watchdog_ch, 30 * hz, + pmswatchdog, sc); return(0); } @@ -313,7 +315,7 @@ pmsclose(dev, flag, mode, p) struct pms_softc *sc = opms_cd.cd_devs[PMSUNIT(dev)]; /* remove the timeout */ - untimeout(pmswatchdog, (void *) sc); + callout_stop(&sc->sc_watchdog_ch); /* disable interrupts */ sc->sc_intenable(sc, 0); diff --git a/sys/arch/arm32/dev/pmsvar.h b/sys/arch/arm32/dev/pmsvar.h index fdadea813e44..07da0f74abae 100644 --- a/sys/arch/arm32/dev/pmsvar.h +++ b/sys/arch/arm32/dev/pmsvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmsvar.h,v 1.1 1997/10/14 19:35:35 mark Exp $ */ +/* $NetBSD: pmsvar.h,v 1.2 2000/03/23 06:35:14 thorpej Exp $ */ /* * Copyright (c) 1997 Mark Brinicombe. @@ -43,6 +43,8 @@ * softc structure for the pms device */ +#include + struct pms_softc { struct device sc_dev; /* device node */ void *sc_ih; /* interrupt pointer */ @@ -50,6 +52,8 @@ struct pms_softc { bus_space_handle_t sc_ioh; /* bus handle */ int sc_irqnum; /* interrupt number */ + struct callout sc_watchdog_ch; + void (*sc_intenable) __P((struct pms_softc *, int)); struct proc *sc_proc; diff --git a/sys/arch/arm32/footbridge/footbridge_com.c b/sys/arch/arm32/footbridge/footbridge_com.c index 4c78e4e2cf5d..1f775093356d 100644 --- a/sys/arch/arm32/footbridge/footbridge_com.c +++ b/sys/arch/arm32/footbridge/footbridge_com.c @@ -1,4 +1,4 @@ -/* $NetBSD: footbridge_com.c,v 1.4 2000/03/06 21:36:06 thorpej Exp $ */ +/* $NetBSD: footbridge_com.c,v 1.5 2000/03/23 06:35:15 thorpej Exp $ */ /*- * Copyright (c) 1997 Mark Brinicombe @@ -75,6 +75,7 @@ struct fcom_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; void *sc_ih; + struct callout sc_softintr_ch; int sc_rx_irq; int sc_tx_irq; int sc_hwflags; @@ -175,6 +176,7 @@ fcom_attach(parent, self, aux) /* Set up the softc */ sc->sc_iot = fba->fba_fca.fca_iot; sc->sc_ioh = fba->fba_fca.fca_ioh; + callout_init(&sc->sc_softintr_ch); sc->sc_rx_irq = fba->fba_fca.fca_rx_irq; sc->sc_tx_irq = fba->fba_fca.fca_tx_irq; sc->sc_hwflags = 0; @@ -392,7 +394,7 @@ fcomstart(tp) s = splserial(); if (bus_space_read_4(iot, ioh, UART_FLAGS) & UART_TX_BUSY) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, (void *)tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); (void)splx(s); return; } @@ -416,7 +418,7 @@ fcomstart(tp) tp->t_state &= ~TS_BUSY; if (cl->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, (void *)tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } if (cl->c_cc <= tp->t_lowat) { if (tp->t_state & TS_ASLEEP) { @@ -592,7 +594,8 @@ fcom_rxintr(arg) sc->sc_rxbuf[sc->sc_rxpos++] = byte; if (!softint_scheduled) { softint_scheduled = 1; - timeout(fcom_softintr, sc, 1); + callout_reset(&sc->sc_softintr_ch, + 1, fcom_softintr, sc); } } } while (1); diff --git a/sys/arch/arm32/mainbus/fd.c b/sys/arch/arm32/mainbus/fd.c index 51fdc8f69df0..af025aca1090 100644 --- a/sys/arch/arm32/mainbus/fd.c +++ b/sys/arch/arm32/mainbus/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.27 2000/02/07 20:16:49 thorpej Exp $ */ +/* $NetBSD: fd.c,v 1.28 2000/03/23 06:35:15 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -96,6 +96,7 @@ #include #include +#include #include #include #include @@ -161,6 +162,9 @@ struct fdc_softc { bus_space_tag_t sc_iot; /* ISA i/o space identifier */ bus_space_handle_t sc_ioh; /* ISA io handle */ + struct callout sc_timo_ch; /* timeout callout */ + struct callout sc_intr_ch; /* pseudo-intr callout */ + int sc_drq; struct fd_softc *sc_fd[4]; /* pointers to children */ @@ -224,6 +228,8 @@ struct fd_softc { struct fd_type *sc_type; /* current type descriptor */ struct fd_type sc_type_copy; /* copy for fiddling when formatting */ + struct callout sc_motor_ch; + daddr_t sc_blkno; /* starting block number */ int sc_bcount; /* byte count left */ int sc_opts; /* user-set options */ @@ -414,6 +420,9 @@ fdcattach(parent, self, aux) printf("\n"); + callout_init(&fdc->sc_timo_ch); + callout_init(&fdc->sc_intr_ch); + #ifdef NEWCONFIG at_setup_dmachan(fdc->sc_drq, FDC_MAXIOSIZE); isa_establish(&fdc->sc_id, &fdc->sc_dev); @@ -515,6 +524,8 @@ fdattach(parent, self, aux) struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + callout_init(&fd->sc_motor_ch); + /* XXX Allow `flags' to override device type? */ if (type) @@ -632,7 +643,7 @@ fdstrategy(bp) /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort_cylinder(&fd->sc_q, bp); - untimeout(fd_motor_off, fd); /* a good idea */ + callout_stop(&fd->sc_motor_ch); /* a good idea */ if (fd->sc_active == 0) fdstart(fd); #ifdef DIAGNOSTIC @@ -698,7 +709,7 @@ fdfinish(fd, bp) biodone(bp); /* turn off motor 5s from now */ - timeout(fd_motor_off, fd, 5 * hz); + callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; } @@ -1001,7 +1012,7 @@ loop: fd->sc_skip = 0; fd->sc_bcount = bp->b_bcount; fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); - untimeout(fd_motor_off, fd); + callout_stop(&fd->sc_motor_ch); if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { fdc->sc_state = MOTORWAIT; return 1; @@ -1010,14 +1021,15 @@ loop: /* Turn on the motor, being careful about pairing. */ struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; if (ofd && ofd->sc_flags & FD_MOTOR) { - untimeout(fd_motor_off, ofd); + callout_stop(&ofd->sc_motor_ch); ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); } fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; fd_set_motor(fdc, 0); fdc->sc_state = MOTORWAIT; /* Allow .25s for motor to stabilize. */ - timeout(fd_motor_on, fd, hz / 4); + callout_reset(&fd->sc_motor_ch, hz / 4, + fd_motor_on, fd); return 1; } /* Make sure the right drive is selected. */ @@ -1049,7 +1061,7 @@ loop: fd->sc_dk.dk_seek++; disk_busy(&fd->sc_dk); - timeout(fdctimeout, fdc, 4 * hz); + callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc); return 1; case DOIO: @@ -1139,14 +1151,16 @@ loop: disk_busy(&fd->sc_dk); /* allow 2 seconds for operation */ - timeout(fdctimeout, fdc, 2 * hz); + callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc); return 1; /* will return later */ case SEEKWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = SEEKCOMPLETE; /* allow 1/50 second for heads to settle */ -/* timeout(fdcpseudointr, fdc, hz / 50);*/ +#if 0 + callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc); +#endif return 1; case SEEKCOMPLETE: @@ -1180,7 +1194,7 @@ loop: goto loop; case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid)); @@ -1234,11 +1248,11 @@ loop: delay(100); fd_set_motor(fdc, 0); fdc->sc_state = RESETCOMPLETE; - timeout(fdctimeout, fdc, hz / 2); + callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc); return 1; /* will return later */ case RESETCOMPLETE: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); /* clear the controller output buffer */ for (i = 0; i < 4; i++) { out_fdc(iot, ioh, NE7CMD_SENSEI); @@ -1250,14 +1264,16 @@ loop: out_fdc(iot, ioh, NE7CMD_RECAL); /* recalibrate function */ out_fdc(iot, ioh, fd->sc_drive); fdc->sc_state = RECALWAIT; - timeout(fdctimeout, fdc, 5 * hz); + callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc); return 1; /* will return later */ case RECALWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = RECALCOMPLETE; /* allow 1/30 second for heads to settle */ -/* timeout(fdcpseudointr, fdc, hz / 30);*/ +#if 0 + callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc); +#endif return 1; /* will return later */ case RECALCOMPLETE: diff --git a/sys/arch/arm32/mainbus/wdc_pioc.c b/sys/arch/arm32/mainbus/wdc_pioc.c index efe435bbcf4f..7f505012eefd 100644 --- a/sys/arch/arm32/mainbus/wdc_pioc.c +++ b/sys/arch/arm32/mainbus/wdc_pioc.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_pioc.c,v 1.11 1998/12/31 09:37:12 mark Exp $ */ +/* $NetBSD: wdc_pioc.c,v 1.12 2000/03/23 06:35:15 thorpej Exp $ */ /* * Copyright (c) 1997-1998 Mark Brinicombe. @@ -82,7 +82,7 @@ wdc_pioc_probe(parent, cf, aux) void *aux; { struct pioc_attach_args *pa = aux; - struct channel_softc ch = { 0 }; + struct channel_softc ch; int res; u_int iobase; @@ -93,6 +93,8 @@ wdc_pioc_probe(parent, cf, aux) if (pa->pa_offset == PIOCCF_OFFSET_DEFAULT) return(0); + memset(&ch, 0, sizeof(ch)); + iobase = pa->pa_iobase + pa->pa_offset; ch.cmd_iot = pa->pa_iot; ch.ctl_iot = pa->pa_iot; diff --git a/sys/arch/arm32/podulebus/sbic.c b/sys/arch/arm32/podulebus/sbic.c index 64679cfd4be5..24dacdceaa3c 100644 --- a/sys/arch/arm32/podulebus/sbic.c +++ b/sys/arch/arm32/podulebus/sbic.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbic.c,v 1.14 2000/01/18 19:36:58 thorpej Exp $ */ +/* $NetBSD: sbic.c,v 1.15 2000/03/23 06:35:15 thorpej Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -894,6 +894,7 @@ sbicinit(dev) TAILQ_INIT(&dev->ready_list); TAILQ_INIT(&dev->nexus_list); TAILQ_INIT(&dev->free_list); + callout_init(&dev->sc_timo_ch); dev->sc_nexus = NULL; dev->sc_xs = NULL; acb = dev->sc_acb; @@ -909,7 +910,8 @@ sbicinit(dev) bzero(dev->sc_tinfo, sizeof(dev->sc_tinfo)); #ifdef DEBUG /* make sure timeout is really not needed */ - timeout((void *)sbictimeout, dev, 30 * hz); + callout_reset(&dev->sc_timo_ch, 30 * hz, + (void *)sbictimeout, dev); #endif } else panic("sbic: reinitializing driver!"); @@ -2817,7 +2819,8 @@ void sbictimeout(dev) dev->sc_dmatimo++; } splx(s); - timeout((void *)sbictimeout, dev, 30 * hz); + callout_reset(&dev->sc_timo_ch, 30 * hz, + (void *)sbictimeout, dev); } void diff --git a/sys/arch/arm32/podulebus/sbicvar.h b/sys/arch/arm32/podulebus/sbicvar.h index 628aec7cee0e..c8c30252f6c5 100644 --- a/sys/arch/arm32/podulebus/sbicvar.h +++ b/sys/arch/arm32/podulebus/sbicvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sbicvar.h,v 1.4 1998/11/19 21:45:00 thorpej Exp $ */ +/* $NetBSD: sbicvar.h,v 1.5 2000/03/23 06:35:16 thorpej Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -41,6 +41,7 @@ #ifndef _SBICVAR_H_ #define _SBICVAR_H_ #include +#include /* * The largest single request will be MAXPHYS bytes which will require @@ -106,6 +107,7 @@ struct sbic_tinfo { struct sbic_softc { struct device sc_dev; /* struct isr sc_isr;*/ + struct callout sc_timo_ch; struct target_sync { u_char state; u_char period; diff --git a/sys/arch/arm32/shark/pccons.c b/sys/arch/arm32/shark/pccons.c index 048ae2e6ec01..2596dc0c9977 100644 --- a/sys/arch/arm32/shark/pccons.c +++ b/sys/arch/arm32/shark/pccons.c @@ -1,4 +1,4 @@ -/* $NetBSD: pccons.c,v 1.8 1999/03/19 04:58:45 cgd Exp $ */ +/* $NetBSD: pccons.c,v 1.9 2000/03/23 06:35:16 thorpej Exp $ */ /* * Copyright 1997 @@ -255,6 +255,7 @@ struct pc_softc } vs; }; +static struct callout async_update_ch = CALLOUT_INITIALIZER; /* ** Forward routine declarations @@ -782,7 +783,7 @@ async_update(struct pc_softc *sc, */ if (sc->sc_flags & SC_ASYNC_SCHEDULED) { - untimeout(do_async_update, NULL); + callout_stop(&async_update_ch); } do_async_update(sc); } @@ -791,7 +792,7 @@ async_update(struct pc_softc *sc, /* Schedule an update */ sc->sc_flags |= SC_ASYNC_SCHEDULED; - timeout(do_async_update, sc, 1); + callout_reset(&async_update_ch, 1, do_async_update, sc); } return; @@ -1780,7 +1781,7 @@ pcstart(struct tty *tp) if (cl->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } /* ** Check if we are under the low water mark and diff --git a/sys/arch/arm32/shark/sequoia.c b/sys/arch/arm32/shark/sequoia.c index 9504532e0a82..4c00837dbb32 100644 --- a/sys/arch/arm32/shark/sequoia.c +++ b/sys/arch/arm32/shark/sequoia.c @@ -1,4 +1,4 @@ -/* $NetBSD: sequoia.c,v 1.4 1999/03/19 05:13:17 cgd Exp $ */ +/* $NetBSD: sequoia.c,v 1.5 2000/03/23 06:35:16 thorpej Exp $ */ /* * Copyright 1997 @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -133,6 +134,7 @@ static int ledColor; /* present color of led */ static int ledBlockCount;; /* reference count of block calles */ int sequoia_index_cache = -1; /* set to silly value so that we dont cache on init */ +static struct callout led_timo_ch = CALLOUT_INITIALIZER; /* ** @@ -194,7 +196,7 @@ void sequoiaInit(void) ledLastActive.tv_usec = 0; ledLastActive.tv_sec = 0; ledBlockCount = 0; - timeout(ledTimeout,NULL,LED_TIMEOUT); + callout_reset(&led_timo_ch, LED_TIMEOUT, ledTimeout, NULL); /* ** ** setup the pins associated with the smart card reader * @@ -545,7 +547,7 @@ static void ledTimeout(void * arg) } /* resubmint the timeout */ - timeout(ledTimeout,NULL,LED_TIMEOUT); + callout_reset(&led_timo_ch, LED_TIMEOUT, ledTimeout, NULL); } diff --git a/sys/arch/arm32/vidc/console/console.c b/sys/arch/arm32/vidc/console/console.c index 8d40a4a308f6..96fb21c46869 100644 --- a/sys/arch/arm32/vidc/console/console.c +++ b/sys/arch/arm32/vidc/console/console.c @@ -1,4 +1,4 @@ -/* $NetBSD: console.c,v 1.17 2000/03/16 23:21:10 darrenr Exp $ */ +/* $NetBSD: console.c,v 1.18 2000/03/23 06:35:17 thorpej Exp $ */ /* * Copyright (c) 1994-1995 Melvyn Tang-Richardson @@ -737,7 +737,7 @@ physconstart(tp) if (cl->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } if (cl->c_cc <= tp->t_lowat) { diff --git a/sys/arch/arm32/vidc/lmcaudio.c b/sys/arch/arm32/vidc/lmcaudio.c index 42ff2df06681..795ba58e6439 100644 --- a/sys/arch/arm32/vidc/lmcaudio.c +++ b/sys/arch/arm32/vidc/lmcaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: lmcaudio.c,v 1.24 1999/07/08 18:05:26 thorpej Exp $ */ +/* $NetBSD: lmcaudio.c,v 1.25 2000/03/23 06:35:17 thorpej Exp $ */ /* * Copyright (c) 1996, Danny C Tsen. @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -87,6 +88,8 @@ struct audio_general { int drain; } ag; +static struct callout ag_drain_ch = CALLOUT_INITIALIZER; + struct lmcaudio_softc { struct device device; int iobase; @@ -338,7 +341,7 @@ lmcaudio_drain(addr) void *addr; { ag.drain = 1; - timeout(lmcaudio_timeout, &ag.drain, 30 * hz); + callout_reset(&ag_drain_ch, 30 * hz, lmcaudio_timeout, &ag.drain); (void) tsleep(lmcaudio_timeout, PWAIT | PCATCH, "lmcdrain", 0); ag.drain = 0; return(0); @@ -664,7 +667,7 @@ lmcaudio_intr(arg) } if (xcur == 0) { - untimeout(lmcaudio_timeout, &ag.drain); + callout_stop(&ag_drain_ch); wakeup(lmcaudio_timeout); return(0); #if 0 diff --git a/sys/arch/atari/dev/fd.c b/sys/arch/atari/dev/fd.c index 01a93abfca77..740b3fcdef08 100644 --- a/sys/arch/atari/dev/fd.c +++ b/sys/arch/atari/dev/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.34 2000/03/13 23:52:28 soren Exp $ */ +/* $NetBSD: fd.c,v 1.35 2000/03/23 06:36:03 thorpej Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. @@ -50,6 +50,7 @@ #include #include +#include #include #include #include @@ -132,6 +133,7 @@ struct fd_softc { struct device sc_dv; /* generic device info */ struct disk dkdev; /* generic disk info */ struct buf_queue bufq; /* queue of buf's */ + struct callout sc_motor_ch; int unit; /* unit for atari controlling hw*/ int nheads; /* number of heads in use */ int nsectors; /* number of sectors/track */ @@ -315,6 +317,7 @@ void *auxp; } if(nfound) { + struct fd_softc *fdsc = getsoftc(fd_cd, first_found); /* * Make sure motor will be turned of when a floppy is @@ -322,7 +325,7 @@ void *auxp; */ fdselect(first_found, 0, FLP_DD); fd_state = FLP_MON; - timeout((FPV)fdmotoroff, (void*)getsoftc(fd_cd,first_found), 0); + callout_reset(&fdsc->sc_motor_ch, 0, (FPV)fdmotoroff, fdsc); /* * enable disk related interrupts @@ -376,6 +379,8 @@ void *auxp; sc = (struct fd_softc *)dp; + callout_init(&sc->sc_motor_ch); + /* * Find out if an Ajax chip might be installed. Set the default * floppy type accordingly. @@ -623,7 +628,7 @@ struct buf *bp; disksort_blkno(&sc->bufq, bp); /* XXX disksort_cylinder */ if (!lock_stat) { if (fd_state & FLP_MON) - untimeout((FPV)fdmotoroff, (void*)sc); + callout_stop(&sc->sc_motor_ch); fd_state = FLP_IDLE; st_dmagrab((dma_farg)fdcint, (dma_farg)fdstart, sc, &lock_stat, 0); @@ -776,7 +781,8 @@ register struct fd_softc *sc; if (BUFQ_FIRST(&sc1->bufq) != NULL) break; if(i == sc->unit) { - timeout((FPV)fdmotoroff, (void*)sc, FLP_MONDELAY); + callout_reset(&sc->sc_motor_ch, FLP_MONDELAY, + (FPV)fdmotoroff, sc); #ifdef FLP_DEBUG printf("fddone: Nothing to do\n"); #endif @@ -895,7 +901,8 @@ struct fd_softc *sc; */ fd_cmd = RESTORE; write_fdreg(FDC_CS, RESTORE|VBIT|hbit); - timeout((FPV)fdmotoroff, (void*)sc, FLP_XFERDELAY); + callout_reset(&sc->sc_motor_ch, FLP_XFERDELAY, + (FPV)fdmotoroff, sc); #ifdef FLP_DEBUG printf("fd_xfer:Recalibrating drive %d\n", sc->unit); @@ -913,7 +920,8 @@ struct fd_softc *sc; sc->curtrk = track; /* be optimistic */ write_fdreg(FDC_DR, track); write_fdreg(FDC_CS, SEEK|RATE6|VBIT|hbit); - timeout((FPV)fdmotoroff, (void*)sc, FLP_XFERDELAY); + callout_reset(&sc->sc_motor_ch, FLP_XFERDELAY, + (FPV)fdmotoroff, sc); fd_cmd = SEEK; #ifdef FLP_DEBUG printf("fd_xfer:Seek to track %d on drive %d\n",track,sc->unit); @@ -957,7 +965,7 @@ struct fd_softc *sc; write_fdreg(DMA_WRBIT | FDC_CS, F_WRITE|hbit|EBIT|PBIT); fd_cmd = F_WRITE; } - timeout((FPV)fdmotoroff, (void*)sc, FLP_XFERDELAY); + callout_reset(&sc->sc_motor_ch, FLP_XFERDELAY, (FPV)fdmotoroff, sc); } /* return values of fd_xfer_ok(): */ @@ -982,7 +990,7 @@ struct fd_softc *sc; /* * Cancel timeout (we made it, didn't we) */ - untimeout((FPV)fdmotoroff, (void*)sc); + callout_stop(&sc->sc_motor_ch); switch(fd_xfer_ok(sc)) { case X_ERROR : @@ -1267,7 +1275,9 @@ struct fd_softc *fdsoftc; fddeselect(); fd_state = FLP_IDLE; } - else timeout((FPV)fdmotoroff, (void*)fdsoftc, 10*FLP_MONDELAY); + else + callout_reset(&fdsoftc->sc_motor_ch, 10*FLP_MONDELAY, + (FPV)fdmotoroff, fdsoftc); } st_dmafree(fdsoftc, &tmp); } diff --git a/sys/arch/atari/dev/hdfd.c b/sys/arch/atari/dev/hdfd.c index 4aa8ea5d07ba..dbaaeb09698d 100644 --- a/sys/arch/atari/dev/hdfd.c +++ b/sys/arch/atari/dev/hdfd.c @@ -1,4 +1,4 @@ -/* $NetBSD: hdfd.c,v 1.19 2000/02/07 20:16:50 thorpej Exp $ */ +/* $NetBSD: hdfd.c,v 1.20 2000/03/23 06:36:04 thorpej Exp $ */ /*- * Copyright (c) 1996 Leo Weppelman @@ -62,6 +62,7 @@ #include #include +#include #include #include #include @@ -152,6 +153,10 @@ enum fdc_state { /* software state, per controller */ struct fdc_softc { struct device sc_dev; /* boilerplate */ + + struct callout sc_timo_ch; /* timeout callout */ + struct callout sc_intr_ch; /* pseudo-intr callout */ + struct fd_softc *sc_fd[4]; /* pointers to children */ TAILQ_HEAD(drivehead, fd_softc) sc_drives; enum fdc_state sc_state; @@ -212,6 +217,8 @@ struct fd_softc { struct fd_type *sc_deftype; /* default type descriptor */ struct fd_type *sc_type; /* current type descriptor */ + struct callout sc_motor_ch; + daddr_t sc_blkno; /* starting block number */ int sc_bcount; /* byte count left */ int sc_opts; /* user-set options */ @@ -379,6 +386,9 @@ fdcattach(parent, self, aux) printf("\n"); + callout_init(&fdc->sc_timo_ch); + callout_init(&fdc->sc_intr_ch); + if (intr_establish(22, USER_VEC|FAST_VEC, 0, (hw_ifun_t)(has_fifo ? mfp_hdfd_fifo : mfp_hdfd_nf), NULL) == NULL) { @@ -470,6 +480,8 @@ fdattach(parent, self, aux) struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + callout_init(&fd->sc_motor_ch); + /* XXX Allow `flags' to override device type? */ if (type) @@ -595,7 +607,7 @@ fdstrategy(bp) /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort_cylinder(&fd->sc_q, bp); - untimeout(fd_motor_off, fd); /* a good idea */ + callout_stop(&fd->sc_motor_ch); /* a good idea */ if (fd->sc_active == 0) fdstart(fd); #ifdef DIAGNOSTIC @@ -661,7 +673,7 @@ fdfinish(fd, bp) biodone(bp); /* turn off motor 5s from now */ - timeout(fd_motor_off, fd, 5 * hz); + callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; } @@ -951,7 +963,7 @@ loop: fd->sc_skip = 0; fd->sc_bcount = bp->b_bcount; fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); - untimeout(fd_motor_off, fd); + callout_stop(&fd->sc_motor_ch); if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { fdc->sc_state = MOTORWAIT; return 1; @@ -960,14 +972,15 @@ loop: /* Turn on the motor, being careful about pairing. */ struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; if (ofd && ofd->sc_flags & FD_MOTOR) { - untimeout(fd_motor_off, ofd); + callout_stop(&ofd->sc_motor_ch); ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); } fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; fd_set_motor(fdc, 0); fdc->sc_state = MOTORWAIT; /* Allow .25s for motor to stabilize. */ - timeout(fd_motor_on, fd, hz / 4); + callout_reset(&fd->sc_motor_ch, hz / 4, + fd_motor_on, fd); return 1; } /* Make sure the right drive is selected. */ @@ -995,7 +1008,7 @@ loop: fd->sc_dk.dk_seek++; disk_busy(&fd->sc_dk); - timeout(fdctimeout, fdc, 4 * hz); + callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc); return 1; case DOIO: @@ -1075,14 +1088,14 @@ loop: disk_busy(&fd->sc_dk); /* allow 2 seconds for operation */ - timeout(fdctimeout, fdc, 2 * hz); + callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc); return 1; /* will return later */ case SEEKWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = SEEKCOMPLETE; /* allow 1/50 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 50); + callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc); return 1; case SEEKCOMPLETE: @@ -1109,7 +1122,7 @@ loop: goto loop; case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid)); @@ -1154,11 +1167,11 @@ loop: delay(100); fd_set_motor(fdc, 0); fdc->sc_state = RESETCOMPLETE; - timeout(fdctimeout, fdc, hz / 2); + callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc); return 1; /* will return later */ case RESETCOMPLETE: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); /* clear the controller output buffer */ for (i = 0; i < 4; i++) { out_fdc(NE7CMD_SENSEI); @@ -1172,14 +1185,14 @@ loop: out_fdc(NE7CMD_RECAL); /* recalibrate function */ out_fdc(fd->sc_drive); fdc->sc_state = RECALWAIT; - timeout(fdctimeout, fdc, 5 * hz); + callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc); return 1; /* will return later */ case RECALWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = RECALCOMPLETE; /* allow 1/30 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 30); + callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc); return 1; /* will return later */ case RECALCOMPLETE: diff --git a/sys/arch/atari/dev/ite.c b/sys/arch/atari/dev/ite.c index 89c56aec4559..06ee97739995 100644 --- a/sys/arch/atari/dev/ite.c +++ b/sys/arch/atari/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.28 2000/02/11 21:42:52 leo Exp $ */ +/* $NetBSD: ite.c,v 1.29 2000/03/23 06:36:04 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -634,7 +635,7 @@ itestart(tp) /* we have characters remaining. */ if (rbp->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } /* wakeup we are below */ if (rbp->c_cc <= tp->t_lowat) { @@ -878,6 +879,8 @@ enum caller caller; static u_int last_char; static u_char tout_pending; +static struct callout repeat_ch = CALLOUT_INITIALIZER; + /*ARGSUSED*/ static void repeat_handler(arg) @@ -927,7 +930,7 @@ enum caller caller; */ if (up) { if(tout_pending) { - untimeout(repeat_handler, 0); + callout_stop(&repeat_ch); tout_pending = 0; last_char = 0; } @@ -938,7 +941,7 @@ enum caller caller; /* * Different character, stop also */ - untimeout(repeat_handler, 0); + callout_stop(&repeat_ch); tout_pending = 0; last_char = 0; } @@ -1009,13 +1012,15 @@ enum caller caller; if(!tout_pending && caller == ITEFILT_TTY && kbd_ite->key_repeat) { tout_pending = 1; last_char = c; - timeout(repeat_handler, 0, start_repeat_timeo * hz / 100); + callout_reset(&repeat_ch, start_repeat_timeo * hz / 100, + repeat_handler, NULL); } else if(!tout_pending && caller==ITEFILT_REPEATER && kbd_ite->key_repeat) { tout_pending = 1; last_char = c; - timeout(repeat_handler, 0, next_repeat_timeo * hz / 100); + callout_reset(&repeat_ch, next_repeat_timeo * hz / 100, + repeat_handler, NULL); } /* handle dead keys */ if (key.mode & KBD_MODE_DEAD) { diff --git a/sys/arch/atari/dev/lpt.c b/sys/arch/atari/dev/lpt.c index 2768c9261e61..72aef6fe9f8e 100644 --- a/sys/arch/atari/dev/lpt.c +++ b/sys/arch/atari/dev/lpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: lpt.c,v 1.15 1999/04/06 19:31:37 pk Exp $ */ +/* $NetBSD: lpt.c,v 1.16 2000/03/23 06:36:04 thorpej Exp $ */ /* * Copyright (c) 1996 Leo Weppelman @@ -57,6 +57,7 @@ #include #include +#include #include #include #include @@ -89,6 +90,7 @@ int lptdebug = 1; struct lpt_softc { struct device sc_dev; + struct callout sc_wakeup_ch; size_t sc_count; struct buf *sc_inbuf; u_char *sc_cp; @@ -158,6 +160,8 @@ void *auxp; ym2149_strobe(1); printf("\n"); + + callout_init(&sc->sc_wakeup_ch); } /* @@ -235,7 +239,7 @@ lptwakeup(arg) lptpseudointr(sc); - timeout(lptwakeup, sc, STEP); + callout_reset(&sc->sc_wakeup_ch, STEP, lptwakeup, sc); } /* @@ -256,7 +260,7 @@ lpclose(dev, flag, mode, p) (void) pushbytes(sc); if ((sc->sc_flags & LPT_NOINTR) == 0) { - untimeout(lptwakeup, sc); + callout_stop(&sc->sc_wakeup_ch); sps = splhigh(); MFP->mf_ierb &= ~IB_PBSY; diff --git a/sys/arch/atari/dev/ms.c b/sys/arch/atari/dev/ms.c index 9a76ffe3e325..978a7ce3d644 100644 --- a/sys/arch/atari/dev/ms.c +++ b/sys/arch/atari/dev/ms.c @@ -1,4 +1,4 @@ -/* $NetBSD: ms.c,v 1.9 1996/10/13 04:11:06 christos Exp $ */ +/* $NetBSD: ms.c,v 1.10 2000/03/23 06:36:04 thorpej Exp $ */ /* * Copyright (c) 1995 Leo Weppelman. @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -97,6 +98,7 @@ mouseattach(cnt) { printf("1 mouse configured\n"); ms_softc[0].ms_emul3b = 1; + callout_init(&ms_softc[0].ms_delay_ch); return(NMOUSE); } @@ -178,7 +180,7 @@ int size, type; fe = &ms->ms_events.ev_q[put]; if ((type != KBD_TIMEO_PKG) && ms->ms_emul3b && ms->ms_bq_idx) - untimeout((FPV)ms_3b_delay, (void *)ms); + callout_stop(&ms->ms_delay_ch); /* * Button states are encoded in the lower 3 bits of 'id' @@ -267,7 +269,8 @@ int size, type; } } else if (ms->ms_bq[0].value == VKEY_DOWN) { - timeout((FPV)ms_3b_delay, (void *)ms, 10); + callout_reset(&ms->ms_delay_ch, 10, + (FPV)ms_3b_delay, (void *)ms); goto out; } flush_buttons = 1; diff --git a/sys/arch/atari/dev/msvar.h b/sys/arch/atari/dev/msvar.h index 210d8ff6066e..125629895a06 100644 --- a/sys/arch/atari/dev/msvar.h +++ b/sys/arch/atari/dev/msvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: msvar.h,v 1.1 1996/04/12 08:37:06 leo Exp $ */ +/* $NetBSD: msvar.h,v 1.2 2000/03/23 06:36:04 thorpej Exp $ */ /* * Copyright (c) 1996 Leo Weppelman @@ -54,6 +54,7 @@ struct ms_softc { int ms_dy; /* accumulated dy */ struct firm_event ms_bq[2]; /* Button queue */ int ms_bq_idx; /* Button queue index */ + struct callout ms_delay_ch; }; #ifdef _KERNEL diff --git a/sys/arch/atari/dev/ser.c b/sys/arch/atari/dev/ser.c index 42987b5d6379..b79f813a2cbe 100644 --- a/sys/arch/atari/dev/ser.c +++ b/sys/arch/atari/dev/ser.c @@ -1,4 +1,4 @@ -/* $NetBSD: ser.c,v 1.9 1999/08/06 08:27:31 leo Exp $ */ +/* $NetBSD: ser.c,v 1.10 2000/03/23 06:36:04 thorpej Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -154,6 +154,8 @@ struct ser_softc { struct device sc_dev; struct tty *sc_tty; + struct callout sc_diag_ch; + int sc_overflows; int sc_floods; int sc_errors; @@ -294,6 +296,8 @@ void *auxp; MFP->mf_imrb &= ~(IB_SCTS|IB_SDCD); MFP->mf_imra &= ~(IA_RRDY|IA_RERR|IA_TRDY|IA_TERR); + callout_init(&sc->sc_diag_ch); + #ifdef SERCONSOLE /* * Activate serial console when DCD present... @@ -1080,7 +1084,7 @@ serrxint(sc, tp) if (cc == RXBUFSIZE) { sc->sc_floods++; if (sc->sc_errors++ == 0) - timeout(serdiag, sc, 60 * hz); + callout_reset(&sc->sc_diag_ch, 60 * hz, serdiag, sc); } while (cc--) { @@ -1094,7 +1098,8 @@ serrxint(sc, tp) else if (ISSET(rsr, RSR_OERR)) { sc->sc_overflows++; if (sc->sc_errors++ == 0) - timeout(serdiag, sc, 60 * hz); + callout_reset(&sc->sc_diag_ch, 60 * hz, + serdiag, sc); } code = sc->sc_rbuf[get] | lsrmap[(rsr & (RSR_BREAK|RSR_FERR|RSR_PERR)) >> 3]; diff --git a/sys/arch/atari/dev/wdc_mb.c b/sys/arch/atari/dev/wdc_mb.c index 32a991ac5a3c..1802d0a63e79 100644 --- a/sys/arch/atari/dev/wdc_mb.c +++ b/sys/arch/atari/dev/wdc_mb.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_mb.c,v 1.7 1999/08/06 08:27:31 leo Exp $ */ +/* $NetBSD: wdc_mb.c,v 1.8 2000/03/23 06:36:04 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -87,7 +87,7 @@ wdc_mb_probe(parent, cfp, aux) struct cfdata *cfp; void *aux; { - struct channel_softc ch = { 0 }; + struct channel_softc ch; int result = 0; u_char sv_ierb; @@ -96,6 +96,8 @@ wdc_mb_probe(parent, cfp, aux) if (!atari_realconfig) return 0; + memset(&ch, 0, sizeof(ch)); + ch.cmd_iot = ch.ctl_iot = mb_alloc_bus_space_tag(); if (ch.cmd_iot == NULL) return 0; diff --git a/sys/arch/bebox/isa/fd.c b/sys/arch/bebox/isa/fd.c index 44d8169fe143..9685d26b3cc3 100644 --- a/sys/arch/bebox/isa/fd.c +++ b/sys/arch/bebox/isa/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.11 2000/02/07 22:07:29 thorpej Exp $ */ +/* $NetBSD: fd.c,v 1.12 2000/03/23 06:36:44 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -96,6 +96,7 @@ #include #include +#include #include #include #include @@ -166,6 +167,9 @@ struct fdc_softc { bus_space_handle_t sc_ioh; /* ISA io handle */ isa_chipset_tag_t sc_ic; /* ISA chipset info */ + struct callout sc_timo_ch; /* timeout callout */ + struct callout sc_intr_ch; /* pseudo-intr callout */ + /* * XXX We have port overlap with the first IDE controller. * Until we have a reasonable solution for handling overlap @@ -239,6 +243,8 @@ struct fd_softc { struct fd_type *sc_type; /* current type descriptor */ struct fd_type sc_type_copy; /* copy for fiddling when formatting */ + struct callout sc_motor_ch; + daddr_t sc_blkno; /* starting block number */ int sc_bcount; /* byte count left */ int sc_opts; /* user-set options */ @@ -434,6 +440,9 @@ fdcattach(parent, self, aux) printf("\n"); + callout_init(&fdc->sc_timo_ch); + callout_init(&fdc->sc_intr_ch); + /* Re-map the I/O space. */ if (bus_space_map(iot, ia->ia_iobase, 6 /* XXX FDC_NPORT */, 0, &ioh)) { printf("%s: can't map i/o space\n", fdc->sc_dev.dv_xname); @@ -567,6 +576,8 @@ fdattach(parent, self, aux) struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + callout_init(&fd->sc_motor_ch); + /* XXX Allow `flags' to override device type? */ if (type) @@ -695,7 +706,7 @@ fdstrategy(bp) /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort_cylinder(&fd->sc_q, bp); - untimeout(fd_motor_off, fd); /* a good idea */ + callout_stop(&fd->sc_motor_ch); /* a good idea */ if (fd->sc_active == 0) fdstart(fd); #ifdef DIAGNOSTIC @@ -765,7 +776,7 @@ fdfinish(fd, bp) biodone(bp); /* turn off motor 5s from now */ - timeout(fd_motor_off, fd, 5 * hz); + callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; } @@ -1068,7 +1079,7 @@ loop: fd->sc_skip = 0; fd->sc_bcount = bp->b_bcount; fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); - untimeout(fd_motor_off, fd); + callout_stop(&fd->sc_motor_ch); if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { fdc->sc_state = MOTORWAIT; return 1; @@ -1077,14 +1088,15 @@ loop: /* Turn on the motor, being careful about pairing. */ struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; if (ofd && ofd->sc_flags & FD_MOTOR) { - untimeout(fd_motor_off, ofd); + callout_stop(&ofd->sc_motor_ch); ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); } fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; fd_set_motor(fdc, 0); fdc->sc_state = MOTORWAIT; /* Allow .25s for motor to stabilize. */ - timeout(fd_motor_on, fd, hz / 4); + callout_reset(&fd->sc_motor_ch, hz / 4, + fd_motor_on, fd); return 1; } /* Make sure the right drive is selected. */ @@ -1110,7 +1122,7 @@ loop: fd->sc_dk.dk_seek++; disk_busy(&fd->sc_dk); - timeout(fdctimeout, fdc, 4 * hz); + callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc); return 1; case DOIO: @@ -1183,14 +1195,14 @@ loop: disk_busy(&fd->sc_dk); /* allow 2 seconds for operation */ - timeout(fdctimeout, fdc, 2 * hz); + callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc); return 1; /* will return later */ case SEEKWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = SEEKCOMPLETE; /* allow 1/50 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 50); + callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc); return 1; case SEEKCOMPLETE: @@ -1218,7 +1230,7 @@ loop: goto loop; case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid)); @@ -1256,11 +1268,11 @@ loop: delay(100); fd_set_motor(fdc, 0); fdc->sc_state = RESETCOMPLETE; - timeout(fdctimeout, fdc, hz / 2); + callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc); return 1; /* will return later */ case RESETCOMPLETE: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); /* clear the controller output buffer */ for (i = 0; i < 4; i++) { out_fdc(iot, ioh, NE7CMD_SENSEI); @@ -1272,14 +1284,14 @@ loop: out_fdc(iot, ioh, NE7CMD_RECAL); /* recalibrate function */ out_fdc(iot, ioh, fd->sc_drive); fdc->sc_state = RECALWAIT; - timeout(fdctimeout, fdc, 5 * hz); + callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc); return 1; /* will return later */ case RECALWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = RECALCOMPLETE; /* allow 1/30 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 30); + callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc); return 1; /* will return later */ case RECALCOMPLETE: diff --git a/sys/arch/bebox/isa/isaclock.c b/sys/arch/bebox/isa/isaclock.c index 579fa4c6b906..3642ca9c5292 100644 --- a/sys/arch/bebox/isa/isaclock.c +++ b/sys/arch/bebox/isa/isaclock.c @@ -1,4 +1,4 @@ -/* $NetBSD: isaclock.c,v 1.6 1998/08/15 03:02:35 mycroft Exp $ */ +/* $NetBSD: isaclock.c,v 1.7 2000/03/23 06:36:44 thorpej Exp $ */ /*- * Copyright (c) 1993, 1994 Charles M. Hannum. @@ -90,6 +90,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include +#include #include #include #include @@ -160,10 +161,11 @@ void sysbeep(pitch, period) int pitch, period; { + static struct callout sysbeep_ch = CALLOUT_INITIALIZER; static int last_pitch; if (beeping) - untimeout(sysbeepstop, 0); + callout_stop(&sysbeep_ch); if (pitch == 0 || period == 0) { sysbeepstop(0); last_pitch = 0; @@ -180,7 +182,7 @@ sysbeep(pitch, period) } last_pitch = pitch; beeping = 1; - timeout(sysbeepstop, 0, period); + callout_reset(&sysbeep_ch, period, sysbeepstop, NULL); } void diff --git a/sys/arch/bebox/isa/pccons.c b/sys/arch/bebox/isa/pccons.c index 26969edbe1fc..7727add9c6ce 100644 --- a/sys/arch/bebox/isa/pccons.c +++ b/sys/arch/bebox/isa/pccons.c @@ -1,4 +1,4 @@ -/* $NetBSD: pccons.c,v 1.16 2000/03/06 21:36:07 thorpej Exp $ */ +/* $NetBSD: pccons.c,v 1.17 2000/03/23 06:36:44 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -168,6 +168,8 @@ struct pc_softc { struct tty *sc_tty; }; +static struct callout async_update_ch = CALLOUT_INITIALIZER; + void fillw __P((short, void *, size_t)); int pcprobe __P((struct device *, struct cfdata *, void *)); void pcattach __P((struct device *, struct device *, void *)); @@ -459,13 +461,13 @@ async_update() if (kernel || polling) { if (async) - untimeout(do_async_update, NULL); + callout_stop(&async_update_ch); do_async_update((void *)1); } else { if (async) return; async = 1; - timeout(do_async_update, NULL, 1); + callout_reset(&async_update_ch, 1, do_async_update, NULL); } } @@ -813,7 +815,7 @@ pcstart(tp) tp->t_state &= ~TS_BUSY; if (cl->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } if (cl->c_cc <= tp->t_lowat) { if (tp->t_state & TS_ASLEEP) { diff --git a/sys/arch/bebox/isa/spkr.c b/sys/arch/bebox/isa/spkr.c index c6202a1c1ce2..54465ea36e31 100644 --- a/sys/arch/bebox/isa/spkr.c +++ b/sys/arch/bebox/isa/spkr.c @@ -1,4 +1,4 @@ -/* $NetBSD: spkr.c,v 1.5 1998/09/28 09:33:14 sakamoto Exp $ */ +/* $NetBSD: spkr.c,v 1.6 2000/03/23 06:36:44 thorpej Exp $ */ /* * spkr.c -- device driver for console speaker on 80386 @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -71,6 +72,9 @@ static void playinit __P((void)); static void playtone __P((int, int, int)); static void playstring __P((char *, int)); +static struct callout endtone_ch = CALLOUT_INITIALIZER; +static struct callout endreset_ch = CALLOUT_INITIALIZER; + static void endtone(v) void *v; @@ -107,7 +111,7 @@ void tone(hz, ticks) * This is so other processes can execute while the tone is being * emitted. */ - timeout(endtone, NULL, ticks); + callout_reset(&endtone_ch, ticks, endtone, NULL); sleep(endtone, PZERO - 1); } @@ -132,7 +136,7 @@ rest(ticks) #ifdef DEBUG printf("rest: %d\n", ticks); #endif /* DEBUG */ - timeout(endrest, NULL, ticks); + callout_reset(&endrest_ch, ticks, endrest, NULL); sleep(endrest, PZERO - 1); } diff --git a/sys/arch/hp300/dev/apci.c b/sys/arch/hp300/dev/apci.c index b46660e46813..aa7b0089c034 100644 --- a/sys/arch/hp300/dev/apci.c +++ b/sys/arch/hp300/dev/apci.c @@ -1,4 +1,4 @@ -/* $NetBSD: apci.c,v 1.7 1999/09/10 22:49:33 bad Exp $ */ +/* $NetBSD: apci.c,v 1.8 2000/03/23 06:37:23 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc. @@ -123,6 +123,7 @@ struct apci_softc { struct device sc_dev; /* generic device glue */ struct apciregs *sc_apci; /* device registers */ struct tty *sc_tty; /* tty glue */ + struct callout sc_diag_ch; int sc_ferr, sc_perr, sc_oflow, @@ -230,6 +231,8 @@ apciattach(parent, self, aux) (struct apciregs *)IIOV(FRODO_BASE + fa->fa_offset); sc->sc_flags = 0; + callout_init(&sc->sc_diag_ch); + /* Are we the console? */ if (apci == apci_cn) { sc->sc_flags |= APCI_ISCONSOLE; @@ -359,7 +362,7 @@ apciopen(dev, flag, mode, p) /* clear errors, start timeout */ sc->sc_ferr = sc->sc_perr = sc->sc_oflow = sc->sc_toterr = 0; - timeout(apcitimeout, sc, hz); + callout_reset(&sc->sc_diag_ch, hz, apcitimeout, sc); bad: return (error); @@ -865,7 +868,7 @@ apcitimeout(arg) sc->sc_dev.dv_xname, ferr, perr, oflow, sc->sc_toterr); } - timeout(apcitimeout, sc, hz); + callout_reset(&sc->sc_diag_ch, hz, apcitimeout, sc); } /* diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c index 1ff0918f9526..b121c148de30 100644 --- a/sys/arch/hp300/dev/dma.c +++ b/sys/arch/hp300/dev/dma.c @@ -1,4 +1,4 @@ -/* $NetBSD: dma.c,v 1.24 1999/08/01 21:50:17 thorpej Exp $ */ +/* $NetBSD: dma.c,v 1.25 2000/03/23 06:37:23 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -79,6 +79,7 @@ #include #include +#include #include #include #include @@ -119,6 +120,7 @@ struct dma_softc { struct dmareg *sc_dmareg; /* pointer to our hardware */ struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */ TAILQ_HEAD(, dmaqueue) sc_queue; /* job queue */ + struct callout sc_debug_ch; char sc_type; /* A, B, or C */ int sc_ipl; /* our interrupt level */ void *sc_ih; /* interrupt cookie */ @@ -187,6 +189,7 @@ dmainit() sc->sc_type = (rev == 'B') ? DMA_B : DMA_C; TAILQ_INIT(&sc->sc_queue); + callout_init(&sc->sc_debug_ch); for (i = 0; i < NDMACHAN; i++) { dc = &sc->sc_chan[i]; @@ -210,7 +213,7 @@ dmainit() #ifdef DEBUG /* make sure timeout is really not needed */ - timeout(dmatimeout, sc, 30 * hz); + callout_reset(&sc->sc_debug_ch, 30 * hz, dmatimeout, sc); #endif printf("98620%c, 2 channels, %d bit DMA\n", @@ -621,6 +624,6 @@ dmatimeout(arg) } splx(s); } - timeout(dmatimeout, sc, 30 * hz); + callout_reset(&sc->sc_debug_ch, 30 * hz, dmatimeout, sc); } #endif diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c index de3c9f67749b..dbe333ee82c3 100644 --- a/sys/arch/hp300/dev/fhpib.c +++ b/sys/arch/hp300/dev/fhpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: fhpib.c,v 1.20 1998/01/12 18:30:50 thorpej Exp $ */ +/* $NetBSD: fhpib.c,v 1.21 2000/03/23 06:37:23 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -77,6 +77,7 @@ #include #include +#include #include #include #include @@ -145,6 +146,8 @@ struct fhpib_softc { struct fhpibdevice *sc_regs; /* device registers */ int sc_cmd; struct hpibbus_softc *sc_hpibbus; /* XXX */ + struct callout sc_dmadone_ch; + struct callout sc_ppwatch_ch; }; int fhpibmatch __P((struct device *, struct cfdata *, void *)); @@ -191,6 +194,9 @@ fhpibattach(parent, self, aux) /* Establish the interrupt handler. */ (void) dio_intr_establish(fhpibintr, sc, ipl, IPL_BIO); + callout_init(&sc->sc_dmadone_ch); + callout_init(&sc->sc_ppwatch_ch); + ha.ha_ops = &fhpib_controller; ha.ha_type = HPIBC; /* XXX */ ha.ha_ba = HPIBC_BA; @@ -511,7 +517,8 @@ fhpibdone(hs) if (hs->sc_flags & HPIBF_READ) { hd->hpib_imask = IM_IDLE | IM_BYTE; if (hs->sc_flags & HPIBF_TIMO) - timeout(fhpibdmadone, hs, hz >> 2); + callout_reset(&sc->sc_dmadone_ch, hz >> 2, + fhpibdmadone, hs); } else { cnt = hs->sc_count; if (cnt) { @@ -567,7 +574,7 @@ fhpibintr(arg) hq = hs->sc_queue.tqh_first; if (hs->sc_flags & HPIBF_IO) { if (hs->sc_flags & HPIBF_TIMO) - untimeout(fhpibdmadone, hs); + callout_stop(&sc->sc_dmadone_ch); stat0 = hd->hpib_cmd; hd->hpib_cmd = sc->sc_cmd & ~CT_8BIT; hd->hpib_stat = 0; @@ -676,7 +683,7 @@ fhpibppwatch(arg) hd->hpib_stat = ST_IENAB; hd->hpib_imask = IM_IDLE | IM_ROOM; } else - timeout(fhpibppwatch, sc, 1); + callout_reset(&sc->sc_ppwatch_ch, 1, fhpibppwatch, sc); return; } if ((fhpibdebug & FDB_PPOLL) && sc->sc_dev.dv_unit == fhpibdebugunit) diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c index 4aabcd936bae..e1817ea443e0 100644 --- a/sys/arch/hp300/dev/ite.c +++ b/sys/arch/hp300/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.42 2000/03/13 23:52:28 soren Exp $ */ +/* $NetBSD: ite.c,v 1.43 2000/03/23 06:37:23 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -504,7 +504,7 @@ itestart(tp) } if (hiwat) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } } tp->t_state &= ~TS_BUSY; diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c index 724348be7a01..c6d89f85677b 100644 --- a/sys/arch/hp300/dev/mt.c +++ b/sys/arch/hp300/dev/mt.c @@ -1,4 +1,4 @@ -/* $NetBSD: mt.c,v 1.12 2000/02/06 11:14:56 frueauf Exp $ */ +/* $NetBSD: mt.c,v 1.13 2000/03/23 06:37:24 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -68,6 +68,7 @@ #include #include +#include #include #include #include @@ -98,6 +99,8 @@ int nmtinfo = sizeof(mtinfo) / sizeof(mtinfo[0]); struct mt_softc { struct device sc_dev; + struct callout sc_start_ch; + struct callout sc_intr_ch; int sc_hpibno; /* logical HPIB this slave it attached to */ int sc_slave; /* HPIB slave address (0-6) */ short sc_flags; /* see below */ @@ -180,6 +183,8 @@ mtattach(parent, self, aux) slave = ha->ha_slave; BUFQ_INIT(&sc->sc_tab); + callout_init(&sc->sc_start_ch); + callout_init(&sc->sc_intr_ch); sc->sc_hpibno = hpibno; sc->sc_slave = slave; @@ -580,7 +585,8 @@ mtstart(arg) * but not otherwise. */ if (sc->sc_flags & (MTF_DSJTIMEO | MTF_STATTIMEO)) { - timeout(spl_mtstart, sc, hz >> 5); + callout_reset(&sc->sc_start_ch, hz >> 5, + spl_mtstart, sc); return; } case 2: @@ -666,7 +672,8 @@ mtstart(arg) break; case -2: - timeout(spl_mtstart, sc, hz >> 5); + callout_reset(&sc->sc_start_ch, hz >> 5, + spl_mtstart, sc); return; } @@ -681,7 +688,7 @@ mtstart(arg) sc->sc_dev.dv_xname); goto fatalerror; } - timeout(spl_mtintr, sc, 4 * hz); + callout_reset(&sc->sc_intr_ch, 4 * hz, spl_mtintr, sc); hpibawait(sc->sc_hpibno); return; @@ -816,7 +823,7 @@ mtintr(arg) * to the request for DSJ. It's probably just "busy" figuring * it out and will know in a little bit... */ - timeout(spl_mtintr, sc, hz >> 5); + callout_reset(&sc->sc_intr_ch, hz >> 5, spl_mtintr, sc); return; default: @@ -834,7 +841,7 @@ mtintr(arg) sc->sc_stat3, sc->sc_stat5); if ((bp->b_flags & B_CMD) && bp->b_cmd == MTRESET) - untimeout(spl_mtintr, sc); + callout_stop(&sc->sc_intr_ch); if (sc->sc_stat3 & SR3_POWERUP) sc->sc_flags &= MTF_OPEN | MTF_EXISTS; goto error; @@ -886,7 +893,7 @@ mtintr(arg) sc->sc_flags |= MTF_HITBOF; } if (bp->b_cmd == MTRESET) { - untimeout(spl_mtintr, sc); + callout_stop(&sc->sc_intr_ch); sc->sc_flags |= MTF_ALIVE; } } else { diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c index 78b31a5ad270..6f59dc269603 100644 --- a/sys/arch/hp300/dev/nhpib.c +++ b/sys/arch/hp300/dev/nhpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: nhpib.c,v 1.21 1999/09/17 19:59:41 thorpej Exp $ */ +/* $NetBSD: nhpib.c,v 1.22 2000/03/23 06:37:24 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -77,6 +77,7 @@ #include #include +#include #include #include #include @@ -147,6 +148,8 @@ struct nhpib_softc { struct device sc_dev; /* generic device glue */ struct nhpibdevice *sc_regs; /* device registers */ struct hpibbus_softc *sc_hpibbus; /* XXX */ + struct callout sc_read_ch; + struct callout sc_ppwatch_ch; }; int nhpibmatch __P((struct device *, struct cfdata *, void *)); @@ -204,6 +207,9 @@ nhpibattach(parent, self, aux) /* Establish the interrupt handler. */ (void) dio_intr_establish(nhpibintr, sc, ipl, IPL_BIO); + callout_init(&sc->sc_read_ch); + callout_init(&sc->sc_ppwatch_ch); + ha.ha_ops = &nhpib_controller; ha.ha_type = type; /* XXX */ ha.ha_ba = (type == HPIBA) ? HPIBA_BA : @@ -450,7 +456,8 @@ nhpibdone(hs) if (hs->sc_flags & HPIBF_READ) { if ((hs->sc_flags & HPIBF_TIMO) && (hd->hpib_ids & IDS_IR) == 0) - timeout(nhpibreadtimo, hs, hz >> 2); + calllout_reset(&sc->sc_read_ch, hz >> 2, + nhpibreadtimo, hs); } else { if (hs->sc_count == 1) { (void) nhpibwait(hd, MIS_BO); @@ -492,7 +499,7 @@ nhpibintr(arg) hs->sc_flags &= ~HPIBF_TIMO; dmastop(hs->sc_dq->dq_chan); } else if (hs->sc_flags & HPIBF_TIMO) - untimeout(nhpibreadtimo, hs); + callout_stop(&sc->sc_read_ch); hd->hpib_acr = AUX_TCA; hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); @@ -568,5 +575,5 @@ again: /* timeouts not working yet */ goto again; else - timeout(nhpibppwatch, hs, 1); + callout_reset(&sc->sc_ppwatch_ch, 1, nhpibppwatch, hs); } diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c index e1eea11e3a74..6b1532c4eea6 100644 --- a/sys/arch/hp300/dev/ppi.c +++ b/sys/arch/hp300/dev/ppi.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppi.c,v 1.17 1999/08/05 18:08:10 thorpej Exp $ */ +/* $NetBSD: ppi.c,v 1.18 2000/03/23 06:37:24 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -77,6 +77,7 @@ #include #include +#include #include #include #include @@ -98,6 +99,8 @@ struct ppi_softc { #define sc_delay sc_param.delay int sc_sec; int sc_slave; /* HP-IB slave address */ + struct callout sc_timo_ch; + struct callout sc_start_ch; }; /* sc_flags values */ @@ -175,6 +178,9 @@ ppiattach(parent, self, aux) sc->sc_slave = ha->ha_slave; + callout_init(&sc->sc_timo_ch); + callout_init(&sc->sc_start_ch); + /* Initialize the hpib queue entry. */ sc->sc_hq.hq_softc = sc; sc->sc_hq.hq_slave = sc->sc_slave; @@ -325,7 +331,7 @@ ppirw(dev, uio) sc->sc_flags |= PPIF_UIO; if (sc->sc_timo > 0) { sc->sc_flags |= PPIF_TIMO; - timeout(ppitimo, sc, sc->sc_timo); + callout_reset(&sc->sc_timo_ch, sc->sc_timo, ppitimo, sc); } len = cnt = 0; while (uio->uio_resid > 0) { @@ -352,7 +358,7 @@ again: sc->sc_flags); #endif if (sc->sc_flags & PPIF_TIMO) { - untimeout(ppitimo, sc); + callout_stop(&sc->sc_timo_ch); sc->sc_flags &= ~PPIF_TIMO; } splx(s); @@ -406,7 +412,8 @@ again: */ if (sc->sc_delay > 0) { sc->sc_flags |= PPIF_DELAY; - timeout(ppistart, sc, sc->sc_delay); + callout_reset(&sc->sc_start_ch, sc->sc_delay, + ppistart, sc); error = tsleep(sc, (PCATCH|PZERO) + 1, "hpib", 0); if (error) { splx(s); @@ -427,11 +434,11 @@ again: } s = splsoftclock(); if (sc->sc_flags & PPIF_TIMO) { - untimeout(ppitimo, sc); + callout_stop(&sc->sc_timo_ch); sc->sc_flags &= ~PPIF_TIMO; } if (sc->sc_flags & PPIF_DELAY) { - untimeout(ppistart, sc); + callout_stop(&sc->sc_start_ch); sc->sc_flags &= ~PPIF_DELAY; } splx(s); diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c index 90db99a64453..38f905fc0d1c 100644 --- a/sys/arch/hp300/dev/rd.c +++ b/sys/arch/hp300/dev/rd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rd.c,v 1.40 2000/02/11 23:00:47 kleink Exp $ */ +/* $NetBSD: rd.c,v 1.41 2000/03/23 06:37:24 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -335,6 +335,8 @@ rdattach(parent, self, aux) sc->sc_slave = ha->ha_slave; sc->sc_punit = ha->ha_punit; + callout_init(&sc->sc_restart_ch); + /* Initialize the hpib job queue entry */ sc->sc_hq.hq_softc = sc; sc->sc_hq.hq_slave = sc->sc_slave; @@ -1024,7 +1026,7 @@ rderror(unit) rs->sc_stats.rdtimeouts++; #endif hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq); - timeout(rdrestart, rs, rdtimo * hz); + callout_reset(&rs->sc_restart_ch, rdtimo * hz, rdrestart, rs); return(0); } /* diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h index f1ee46a09bb9..81d223003381 100644 --- a/sys/arch/hp300/dev/rdvar.h +++ b/sys/arch/hp300/dev/rdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: rdvar.h,v 1.8 2000/01/21 23:29:03 thorpej Exp $ */ +/* $NetBSD: rdvar.h,v 1.9 2000/03/23 06:37:24 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,6 +42,8 @@ * @(#)rdvar.h 8.1 (Berkeley) 6/10/93 */ +#include + struct rdidentinfo { short ri_hwid; /* 2 byte HW id */ short ri_maxunum; /* maximum allowed unit number */ @@ -63,6 +65,7 @@ struct rdstats { struct rd_softc { struct device sc_dev; struct disk sc_dkdev; + struct callout sc_restart_ch; int sc_slave; /* HP-IB slave */ int sc_punit; /* physical unit on slave */ int sc_flags; diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index cc4556a47b84..eb7714243da7 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.136 2000/01/19 20:05:34 thorpej Exp $ */ +/* $NetBSD: machdep.c,v 1.137 2000/03/23 06:37:24 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -1101,6 +1102,8 @@ void candbtimer __P((void *)); int crashandburn; +struct callout candbtimer_ch = CALLOUT_INITIALIZER; + void candbtimer(arg) void *arg; @@ -1152,7 +1155,8 @@ nmihand(frame) /* Start the crashandburn sequence */ printf("\n"); crashandburn = 1; - timeout(candbtimer, NULL, hz / candbdiv); + callout_reset(&candbtimer_ch, hz / candbdiv, + candbtiner, NULL); } } else #endif /* PANICBUTTON */ diff --git a/sys/arch/hpcmips/dev/biconsdev.c b/sys/arch/hpcmips/dev/biconsdev.c index 0e1b659b4156..7b0dbbe7ea14 100644 --- a/sys/arch/hpcmips/dev/biconsdev.c +++ b/sys/arch/hpcmips/dev/biconsdev.c @@ -1,4 +1,4 @@ -/* $NetBSD: biconsdev.c,v 1.1.1.1 1999/09/16 12:23:19 takemura Exp $ */ +/* $NetBSD: biconsdev.c,v 1.2 2000/03/23 06:38:02 thorpej Exp $ */ /*- * Copyright (c) 1999 @@ -148,7 +148,7 @@ biconsdev_output(tp) /* Come back if there's more to do */ if (tp->t_outq.c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } if (tp->t_outq.c_cc <= tp->t_lowat) { if (tp->t_state&TS_ASLEEP) { diff --git a/sys/arch/hpcmips/dev/tc5165buf.c b/sys/arch/hpcmips/dev/tc5165buf.c index 55d3e975dafb..c9971ed1b9af 100644 --- a/sys/arch/hpcmips/dev/tc5165buf.c +++ b/sys/arch/hpcmips/dev/tc5165buf.c @@ -1,4 +1,4 @@ -/* $NetBSD: tc5165buf.c,v 1.4 2000/01/16 21:47:01 uch Exp $ */ +/* $NetBSD: tc5165buf.c,v 1.5 2000/03/23 06:38:02 thorpej Exp $ */ /* * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -62,7 +63,8 @@ struct tc5165buf_chip { u_int16_t scc_buf[TC5165_COLUMN_MAX]; int scc_enabled; int scc_queued; - + struct callout scc_soft_ch; + struct skbd_controller scc_controller; }; @@ -111,7 +113,9 @@ tc5165buf_attach(parent, self, aux) printf(": "); sc->sc_tc = ca->ca_tc; sc->sc_chip = &tc5165buf_chip; - + + callout_init(&sc->sc_chip->scc_soft_ch); + sc->sc_chip->scc_cst = ca->ca_csio.cstag; if (bus_space_map(sc->sc_chip->scc_cst, ca->ca_csio.csbase, @@ -205,8 +209,8 @@ tc5165buf_intr(arg) return 0; scc->scc_queued = 1; - timeout(tc5165buf_soft, scc, 1); - + callout_reset(&scc->scc_soft_ch, 1, tc5165buf_soft, scc); + return 0; } diff --git a/sys/arch/hpcmips/tx/txcom.c b/sys/arch/hpcmips/tx/txcom.c index 9c5cdfd07d5d..3ae7b23a1e8f 100644 --- a/sys/arch/hpcmips/tx/txcom.c +++ b/sys/arch/hpcmips/tx/txcom.c @@ -1,4 +1,4 @@ -/* $NetBSD: txcom.c,v 1.7 2000/03/06 21:36:07 thorpej Exp $ */ +/* $NetBSD: txcom.c,v 1.8 2000/03/23 06:38:03 thorpej Exp $ */ /* * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi @@ -87,6 +87,9 @@ struct txcom_softc { struct tty *sc_tty; struct txcom_chip *sc_chip; + struct callout sc_txsoft_ch; + struct callout sc_rxsoft_ch; + u_int8_t *sc_tba; /* transmit buffer address */ int sc_tbc; /* transmit byte count */ int sc_heldtbc; @@ -673,7 +676,7 @@ txcom_rxintr(arg) sc->sc_rbuf[sc->sc_rbput] = c; sc->sc_rbput = (sc->sc_rbput + 1) % TXCOM_RING_MASK; - timeout(txcom_rxsoft, arg, 1); + callout_reset(&sc->sc_rxsoft_ch, 1, txcom_rxsoft, sc); return 0; } @@ -724,7 +727,7 @@ txcom_txintr(arg) sc->sc_tbc--; sc->sc_tba++; } else { - timeout(txcom_txsoft, arg, 1); + callout_reset(&sc->sc_rxsoft_ch, 1, txcom_txsoft, sc); } return 0; diff --git a/sys/arch/i386/isa/fd.c b/sys/arch/i386/isa/fd.c index 614728f3f207..588fd8099746 100644 --- a/sys/arch/i386/isa/fd.c +++ b/sys/arch/i386/isa/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.131 2000/02/07 22:07:30 thorpej Exp $ */ +/* $NetBSD: fd.c,v 1.132 2000/03/23 06:39:15 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -96,6 +96,7 @@ #include #include +#include #include #include #include @@ -166,6 +167,9 @@ struct fdc_softc { bus_space_handle_t sc_ioh; /* ISA io handle */ isa_chipset_tag_t sc_ic; /* ISA chipset info */ + struct callout sc_timo_ch; /* timeout callout */ + struct callout sc_intr_ch; /* pseudo-intr callout */ + /* * XXX We have port overlap with the first IDE controller. * Until we have a reasonable solution for handling overlap @@ -239,6 +243,8 @@ struct fd_softc { struct fd_type *sc_type; /* current type descriptor */ struct fd_type sc_type_copy; /* copy for fiddling when formatting */ + struct callout sc_motor_ch; + daddr_t sc_blkno; /* starting block number */ int sc_bcount; /* byte count left */ int sc_opts; /* user-set options */ @@ -434,6 +440,9 @@ fdcattach(parent, self, aux) printf("\n"); + callout_init(&fdc->sc_timo_ch); + callout_init(&fdc->sc_intr_ch); + /* Re-map the I/O space. */ if (bus_space_map(iot, ia->ia_iobase, 6 /* XXX FDC_NPORT */, 0, &ioh)) { printf("%s: can't map i/o space\n", fdc->sc_dev.dv_xname); @@ -555,6 +564,8 @@ fdattach(parent, self, aux) struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + callout_init(&fd->sc_motor_ch); + /* XXX Allow `flags' to override device type? */ if (type) @@ -683,7 +694,7 @@ fdstrategy(bp) /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort_cylinder(&fd->sc_q, bp); - untimeout(fd_motor_off, fd); /* a good idea */ + callout_stop(&fd->sc_motor_ch); /* a good idea */ if (fd->sc_active == 0) fdstart(fd); #ifdef DIAGNOSTIC @@ -753,7 +764,7 @@ fdfinish(fd, bp) biodone(bp); /* turn off motor 5s from now */ - timeout(fd_motor_off, fd, 5 * hz); + callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; } @@ -1056,7 +1067,7 @@ loop: fd->sc_skip = 0; fd->sc_bcount = bp->b_bcount; fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); - untimeout(fd_motor_off, fd); + callout_stop(&fd->sc_motor_ch); if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { fdc->sc_state = MOTORWAIT; return 1; @@ -1065,14 +1076,15 @@ loop: /* Turn on the motor, being careful about pairing. */ struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; if (ofd && ofd->sc_flags & FD_MOTOR) { - untimeout(fd_motor_off, ofd); + callout_stop(&ofd->sc_motor_ch); ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); } fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; fd_set_motor(fdc, 0); fdc->sc_state = MOTORWAIT; /* Allow .25s for motor to stabilize. */ - timeout(fd_motor_on, fd, hz / 4); + callout_reset(&fd->sc_motor_ch, hz / 4, + fd_motor_on, fd); return 1; } /* Make sure the right drive is selected. */ @@ -1098,7 +1110,7 @@ loop: fd->sc_dk.dk_seek++; disk_busy(&fd->sc_dk); - timeout(fdctimeout, fdc, 4 * hz); + callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc); return 1; case DOIO: @@ -1171,14 +1183,14 @@ loop: disk_busy(&fd->sc_dk); /* allow 2 seconds for operation */ - timeout(fdctimeout, fdc, 2 * hz); + callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc); return 1; /* will return later */ case SEEKWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = SEEKCOMPLETE; /* allow 1/50 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 50); + callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc); return 1; case SEEKCOMPLETE: @@ -1206,7 +1218,7 @@ loop: goto loop; case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid)); @@ -1244,11 +1256,11 @@ loop: delay(100); fd_set_motor(fdc, 0); fdc->sc_state = RESETCOMPLETE; - timeout(fdctimeout, fdc, hz / 2); + callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc); return 1; /* will return later */ case RESETCOMPLETE: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); /* clear the controller output buffer */ for (i = 0; i < 4; i++) { out_fdc(iot, ioh, NE7CMD_SENSEI); @@ -1260,14 +1272,14 @@ loop: out_fdc(iot, ioh, NE7CMD_RECAL); /* recalibrate function */ out_fdc(iot, ioh, fd->sc_drive); fdc->sc_state = RECALWAIT; - timeout(fdctimeout, fdc, 5 * hz); + callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc); return 1; /* will return later */ case RECALWAIT: - untimeout(fdctimeout, fdc); + callout_stop(&fdc->sc_timo_ch); fdc->sc_state = RECALCOMPLETE; /* allow 1/30 second for heads to settle */ - timeout(fdcpseudointr, fdc, hz / 30); + callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc); return 1; /* will return later */ case RECALCOMPLETE: diff --git a/sys/arch/i386/isa/pccons.c b/sys/arch/i386/isa/pccons.c index 3b1e2ed80089..faf9f9aba0eb 100644 --- a/sys/arch/i386/isa/pccons.c +++ b/sys/arch/i386/isa/pccons.c @@ -1,4 +1,4 @@ -/* $NetBSD: pccons.c,v 1.138 2000/03/06 21:36:07 thorpej Exp $ */ +/* $NetBSD: pccons.c,v 1.139 2000/03/23 06:39:15 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -199,6 +199,8 @@ struct pc_softc { struct tty *sc_tty; }; +static struct callout async_update_ch = CALLOUT_INITIALIZER; + int pcprobe __P((struct device *, struct cfdata *, void *)); void pcattach __P((struct device *, struct device *, void *)); int pcintr __P((void *)); @@ -529,13 +531,13 @@ async_update() if (kernel || polling) { if (async) - untimeout(do_async_update, NULL); + callout_stop(&async_update_ch); do_async_update((void *)1); } else { if (async) return; async = 1; - timeout(do_async_update, NULL, 1); + callout_reset(&async_update_ch, 1, do_async_update, NULL); } } @@ -1050,7 +1052,7 @@ pcstart(tp) tp->t_state &= ~TS_BUSY; if (cl->c_cc) { tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); + callout_reset(&tp->t_rstrt_ch, 1, ttrstrt, tp); } if (cl->c_cc <= tp->t_lowat) { if (tp->t_state & TS_ASLEEP) { diff --git a/sys/arch/i386/isa/pcvt/pcvt_kbd.c b/sys/arch/i386/isa/pcvt/pcvt_kbd.c index 3db9a859de8f..d0535ec3e54c 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/arch/i386/isa/pcvt/pcvt_kbd.c @@ -197,6 +197,7 @@ do_vgapage(int page) */ static int lost_intr_timeout_queued = 0; +static struct callout check_for_lost_intr_ch = CALLOUT_INITIALIZER; static void check_for_lost_intr (void *arg) @@ -244,9 +245,10 @@ update_led(void) #if PCVT_UPDLED_LOSES_INTR if (lost_intr_timeout_queued) - untimeout (check_for_lost_intr, (void *)NULL); + callout_stop(&check_for_lost_intr_ch); - timeout (check_for_lost_intr, (void *)NULL, hz); + callout_reset(&check_for_lost_intr_ch, hz, + check_for_lost_intr, NULL); lost_intr_timeout_queued = 1; #endif /* PCVT_UPDLED_LOSES_INTR */ diff --git a/sys/arch/i386/isa/pcvt/pcvt_sup.c b/sys/arch/i386/isa/pcvt/pcvt_sup.c index 01aaf00ca790..ceb86f98ae3a 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_sup.c +++ b/sys/arch/i386/isa/pcvt/pcvt_sup.c @@ -90,6 +90,7 @@ static unsigned char * compute_charset_base ( unsigned fontset ); static void scrnsv_timedout ( void *arg ); static u_short *savedscreen = (u_short *)0; /* ptr to screen contents */ static size_t scrnsv_size = (size_t)-1; /* size of saved image */ +static struct callout scrnsv_timedout_ch = CALLOUT_INITIALIZER; #if PCVT_PRETTYSCRNS static u_short *scrnsv_current = (u_short *)0; /* attention char ptr */ @@ -1748,6 +1749,8 @@ set_2ndcharset(void) #if PCVT_SCREENSAVER #if PCVT_PRETTYSCRNS +static struct callout scrnsv_blink_ch = CALLOUT_INITIALIZER; + /*---------------------------------------------------------------------------* * produce some kinda random number, had a look into the system library... *---------------------------------------------------------------------------*/ @@ -1787,7 +1790,7 @@ scrnsv_blink(void) *scrnsv_current = (7 /* LIGHTGRAY */ << 8) + '*'; if(adaptor_type == VGA_ADAPTOR) vgapaletteio(7 /* LIGHTGRAY */, &blink_rgb[(r >> 4) & 7], 1); - timeout((TIMEOUT_FUNC_T)scrnsv_blink, NULL, hz); + callout_reset(&scrnsv_blink_ch, hz, (TIMEOUT_FUNC_T)scrnsv_blink, NULL); } #endif /* PCVT_PRETTYSCRNS */ @@ -1801,7 +1804,7 @@ pcvt_set_scrnsv_tmo(int timeout) int x = splhigh(); if(scrnsv_timeout) - untimeout((TIMEOUT_FUNC_T)scrnsv_timedout, NULL); + callout_stop(&scrnsv_timedout_ch); scrnsv_timeout = timeout; pcvt_scrnsv_reset(); /* sanity */ @@ -1878,8 +1881,8 @@ scrnsv_timedout(void *arg) vgapaletteio(0 /* BLACK */, &black, 1); } /* prepare for next time... */ - timeout((TIMEOUT_FUNC_T)scrnsv_timedout /* me! */, - NULL, hz / 10); + callout_reset(&scrnsv_timedout_ch, hz / 10, + (TIMEOUT_FUNC_T)scrnsv_timedout, NULL); } else { @@ -1889,7 +1892,8 @@ scrnsv_timedout(void *arg) #if PCVT_PRETTYSCRNS scrnsv_current = vsp->Crtat; - timeout((TIMEOUT_FUNC_T)scrnsv_blink, NULL, hz); + callout_reset(scrnsv_blink_ch, hz, + (TIMEOUT_FUNC_T)scrnsv_blink, NULL); #endif /* PCVT_PRETTYSCRNS */ sw_cursor(0); /* cursor off on mda/cga */ @@ -1917,14 +1921,14 @@ pcvt_scrnsv_reset(void) { last_schedule = time.tv_sec; reschedule = 1; - untimeout((TIMEOUT_FUNC_T)scrnsv_timedout, NULL); + callout_stop(&scrnsv_timedout_ch); } if(scrnsv_active) { #if PCVT_PRETTYSCRNS if(scrnsv_active > 1) - untimeout((TIMEOUT_FUNC_T)scrnsv_blink, NULL); + callout_stop(&scrnsv_blink_ch); #endif /* PCVT_PRETTYSCRNS */ bcopy(savedscreen, vsp->Crtat, scrnsv_size); @@ -1947,8 +1951,8 @@ pcvt_scrnsv_reset(void) if(reschedule) { /* mark next timeout */ - timeout((TIMEOUT_FUNC_T)scrnsv_timedout, NULL, - scrnsv_timeout * hz); + callout_reset(&scrnsv_timedout_ch, scrnsv_timeout * hz, + (TIMEOUT_FUNC_T)scrnsv_timedout, NULL); } splx(x); } diff --git a/sys/arch/mac68k/dev/adb_direct.c b/sys/arch/mac68k/dev/adb_direct.c index ff4772b7cb7e..2464988c597d 100644 --- a/sys/arch/mac68k/dev/adb_direct.c +++ b/sys/arch/mac68k/dev/adb_direct.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb_direct.c,v 1.41 2000/03/19 07:37:58 scottr Exp $ */ +/* $NetBSD: adb_direct.c,v 1.42 2000/03/23 06:39:55 thorpej Exp $ */ /* From: adb_direct.c 2.02 4/18/97 jpw */ @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -266,6 +267,8 @@ int tickle_count = 0; /* how many tickles seen for this packet? */ int tickle_serial = 0; /* the last packet tickled */ int adb_cuda_serial = 0; /* the current packet */ +struct callout adb_cuda_tickle_ch = CALLOUT_INITIALIZER; + extern struct mac68k_machine_S mac68k_machine; void pm_setup_adb __P((void)); @@ -370,7 +373,8 @@ adb_cuda_tickle(void) tickle_count = 0; } - timeout((void *)adb_cuda_tickle, 0, ADB_TICKLE_TICKS); + callout_reset(&adb_cuda_tickle_ch, ADB_TICKLE_TICKS, + (void *)adb_cuda_tickle, NULL); } /* @@ -2331,7 +2335,8 @@ adb_reinit(void) #endif if (adbHardware == ADB_HW_CUDA) - timeout((void *)adb_cuda_tickle, 0, ADB_TICKLE_TICKS); + callout_reset(&adb_cuda_tickle_ch, ADB_TICKLE_TICKS, + (void *)adb_cuda_tickle, NULL); /* ints must be on for PB & IOP (at least, for now) */ if (adbHardware != ADB_HW_PB && adbHardware != ADB_HW_IOP) diff --git a/sys/arch/mac68k/dev/aed.c b/sys/arch/mac68k/dev/aed.c index 8b39c512d6e4..26e12763afce 100644 --- a/sys/arch/mac68k/dev/aed.c +++ b/sys/arch/mac68k/dev/aed.c @@ -1,4 +1,4 @@ -/* $NetBSD: aed.c,v 1.9 2000/02/14 07:01:45 scottr Exp $ */ +/* $NetBSD: aed.c,v 1.10 2000/03/23 06:39:56 thorpej Exp $ */ /* * Copyright (C) 1994 Bradley A. Grantham @@ -99,6 +99,8 @@ aedattach(parent, self, aux) struct adb_attach_args *aa_args = (struct adb_attach_args *)aux; struct aed_softc *sc = (struct aed_softc *)self; + callout_init(&sc->sc_repeat_ch); + sc->origaddr = aa_args->origaddr; sc->adbaddr = aa_args->adbaddr; sc->handler_id = aa_args->handler_id; @@ -319,7 +321,8 @@ aed_kbdrpt(kstate) aed_handoff(&aed_sc->sc_rptevent); /* do key down */ if (aed_sc->sc_repeating == aed_sc->sc_rptevent.u.k.key) { - timeout(aed_kbdrpt, kstate, aed_sc->sc_rptinterval); + callout_reset(&aed_sc->sc_repeat_ch, aed_sc->sc_rptinterval, + aed_kbdrpt, kstate); } } @@ -339,15 +342,16 @@ aed_dokeyupdown(event) if (ADBK_PRESS(event->u.k.key) && keyboard[kbd_key][0] != 0) { /* ignore shift & control */ if (aed_sc->sc_repeating != -1) { - untimeout(aed_kbdrpt, (void *)aed_sc); + callout_stop(&aed_sc->sc_repeat_ch); } aed_sc->sc_rptevent = *event; aed_sc->sc_repeating = kbd_key; - timeout(aed_kbdrpt, (void *)aed_sc, aed_sc->sc_rptdelay); + callout_reset(&aed_sc->sc_repeat_ch, aed_sc->sc_rptdelay, + aed_kbdrpt, (void *)aed_sc); } else { if (aed_sc->sc_repeating != -1) { aed_sc->sc_repeating = -1; - untimeout(aed_kbdrpt, (void *)aed_sc); + callout_stop(&aed_sc->sc_repeat_ch); } aed_sc->sc_rptevent = *event; } diff --git a/sys/arch/mac68k/dev/aedvar.h b/sys/arch/mac68k/dev/aedvar.h index 07184c423574..b7344afc0507 100644 --- a/sys/arch/mac68k/dev/aedvar.h +++ b/sys/arch/mac68k/dev/aedvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: aedvar.h,v 1.3 2000/02/14 07:01:45 scottr Exp $ */ +/* $NetBSD: aedvar.h,v 1.4 2000/03/23 06:39:56 thorpej Exp $ */ /* * Copyright (C) 1994 Bradley A. Grantham @@ -30,6 +30,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include /* Event queue definitions */ @@ -41,6 +42,8 @@ struct aed_softc { struct device sc_dev; + struct callout sc_repeat_ch; + /* ADB info */ int origaddr; /* ADB device type (ADBADDR_AED) */ int adbaddr; /* current ADB address */ diff --git a/sys/arch/mac68k/obio/asc.c b/sys/arch/mac68k/obio/asc.c index 8c419f64e783..9352ecfaadd2 100644 --- a/sys/arch/mac68k/obio/asc.c +++ b/sys/arch/mac68k/obio/asc.c @@ -1,4 +1,4 @@ -/* $NetBSD: asc.c,v 1.33 1999/07/08 18:08:54 thorpej Exp $ */ +/* $NetBSD: asc.c,v 1.34 2000/03/23 06:39:56 thorpej Exp $ */ /* * Copyright (C) 1997 Scott Reynolds @@ -168,6 +168,7 @@ ascattach(parent, self, aux) } sc->sc_open = 0; sc->sc_ringing = 0; + callout_init(&sc->sc_bell_ch); for (i = 0; i < 256; i++) { /* up part of wave, four voices? */ asc_wave_tab[i] = i / 4; @@ -347,9 +348,9 @@ asc_ring_bell(arg, freq, length, volume) bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80f, 0); bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x802, 2); /* sampled */ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x801, 2); /* enable sampled */ + sc->sc_ringing = 1; + callout_reset(&sc->sc_bell_ch, length, asc_stop_bell, sc); } - sc->sc_ringing++; - timeout(asc_stop_bell, sc, length); return (0); } diff --git a/sys/arch/mac68k/obio/ascvar.h b/sys/arch/mac68k/obio/ascvar.h index 48ccb1e9664c..61bc79a1628f 100644 --- a/sys/arch/mac68k/obio/ascvar.h +++ b/sys/arch/mac68k/obio/ascvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ascvar.h,v 1.4 1997/10/10 05:54:57 scottr Exp $ */ +/* $NetBSD: ascvar.h,v 1.5 2000/03/23 06:39:56 thorpej Exp $ */ /* * Copyright (C) 1997 Scott Reynolds. All rights reserved. @@ -26,6 +26,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #define ASCUNIT(d) ((d) & 0x7) struct asc_softc { @@ -34,6 +36,7 @@ struct asc_softc { bus_space_handle_t sc_handle; int sc_open; int sc_ringing; + struct callout sc_bell_ch; }; int ascopen __P((dev_t dev, int flag, int mode, struct proc *p)); diff --git a/sys/arch/mac68k/obio/iwm_fd.c b/sys/arch/mac68k/obio/iwm_fd.c index 0f5e4400ba1a..0a4f0c823e63 100644 --- a/sys/arch/mac68k/obio/iwm_fd.c +++ b/sys/arch/mac68k/obio/iwm_fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: iwm_fd.c,v 1.7 2000/02/24 05:02:33 scottr Exp $ */ +/* $NetBSD: iwm_fd.c,v 1.8 2000/03/23 06:39:56 thorpej Exp $ */ /* * Copyright (c) 1997, 1998 Hauke Fath. All rights reserved. @@ -34,6 +34,7 @@ */ #include #include +#include #include #include #include @@ -469,6 +470,7 @@ fd_attach(parent, self, auxp) iwm->drives++; BUFQ_INIT(&fd->bufQueue); + callout_init(&fd->motor_ch); printf(" drive %d: ", fd->unit); @@ -567,7 +569,7 @@ fd_mod_free(void) * Let's hope there is only one task per drive, * see timeout(9). */ - untimeout(motor_off, iwm->fd[unit]); + callout_stop(&iwm->fd[unit].motor_ch); disk_detach(&iwm->fd[unit]->diskInfo); free(iwm->fd[unit], M_DEVBUF); iwm->fd[unit] = NULL; @@ -1130,7 +1132,7 @@ fdstrategy(bp) bp->b_cylinder); } spl = splbio(); - untimeout(motor_off, fd); + callout_stop(&fd->motor_ch); disksort_cylinder(&fd->bufQueue, bp); if (fd->sc_active == 0) fdstart(fd); @@ -1678,7 +1680,7 @@ fdstart_Exit(fd) * XXX Unloading the module while the timeout is still * running WILL crash the machine. */ - timeout(motor_off, fd, 10 * hz); + callout_reset(&fd->motor_ch, 10 * hz, motor_off, fd); return state_Done; } diff --git a/sys/arch/mac68k/obio/iwm_fdvar.h b/sys/arch/mac68k/obio/iwm_fdvar.h index e1c6c20a73af..22c2a879405b 100644 --- a/sys/arch/mac68k/obio/iwm_fdvar.h +++ b/sys/arch/mac68k/obio/iwm_fdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: iwm_fdvar.h,v 1.4 2000/01/21 23:29:06 thorpej Exp $ */ +/* $NetBSD: iwm_fdvar.h,v 1.5 2000/03/23 06:39:56 thorpej Exp $ */ /* * Copyright (c) 1997, 1998 Hauke Fath. All rights reserved. @@ -134,6 +134,7 @@ struct fd_softc { struct disk diskInfo; /* generic disk info */ struct buf_queue bufQueue; /* queue of buf's */ int sc_active; /* number of active requests */ + struct callout motor_ch; /* motor callout */ /* private stuff here */ /* errors & retries in current I/O job */ diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index ad7f5e19f5b2..cd30b70afe5a 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.164 2000/03/10 01:13:18 enami Exp $ */ +/* $NetBSD: init_main.c,v 1.165 2000/03/23 06:30:07 thorpej Exp $ */ /* * Copyright (c) 1995 Christopher G. Demetriou. All rights reserved. @@ -207,11 +207,14 @@ main() uvm_init(); + /* Initialize callouts. */ + callout_startup(); + /* Do machine-dependent initialization. */ cpu_startup(); - /* Initialize callouts. */ - callout_startup(); + /* Finish initializing callouts. */ + callout_startup1(); /* * Initialize mbuf's. Do this now because we might attempt to @@ -264,6 +267,9 @@ main() p->p_emul = &emul_netbsd; strncpy(p->p_comm, "swapper", MAXCOMLEN); + callout_init(&p->p_realit_ch); + callout_init(&p->p_tsleep_ch); + /* Create credentials. */ cred0.p_refcnt = 1; p->p_cred = &cred0; diff --git a/sys/kern/kern_allocsys.c b/sys/kern/kern_allocsys.c index b0d55bddda64..bfc25cf8eac9 100644 --- a/sys/kern/kern_allocsys.c +++ b/sys/kern/kern_allocsys.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_allocsys.c,v 1.8 1999/12/05 17:12:43 tron Exp $ */ +/* $NetBSD: kern_allocsys.c,v 1.9 2000/03/23 06:30:10 thorpej Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -133,7 +133,10 @@ allocsys(v, mdcallback) caddr_t (*mdcallback) __P((caddr_t)); { - ALLOCSYS(v, callout, struct callout, ncallout); + ALLOCSYS(v, callwheel, struct callout_queue, callwheelsize); +#ifdef CALLWHEEL_STATS + ALLOCSYS(v, callwheel_sizes, int, callwheelsize); +#endif #ifdef SYSVSHM ALLOCSYS(v, shmsegs, struct shmid_ds, shminfo.shmmni); #endif diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index a3db6cb09d86..0c76018354ce 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,41 @@ -/* $NetBSD: kern_clock.c,v 1.51 2000/01/19 20:05:51 thorpej Exp $ */ +/* $NetBSD: kern_clock.c,v 1.52 2000/03/23 06:30:10 thorpej Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -85,12 +122,6 @@ * profhz/stathz for statistics. (For profiling, every tick counts.) */ -/* - * TODO: - * allocate more timeout table slots when table overflows. - */ - - #ifdef NTP /* NTP phase-locked loop in kernel */ /* * Phase/frequency-lock loop (PLL/FLL) definitions @@ -281,7 +312,8 @@ long clock_cpu = 0; /* CPU clock adjust */ int stathz; int profhz; int profprocs; -int ticks; +u_int64_t hardclock_ticks, softclock_ticks; +int softclock_running; /* 1 => softclock() is running */ static int psdiv, pscnt; /* prof => stat divider */ int psratio; /* ratio: prof / stat */ int tickfix, tickfixinterval; /* used if tick not really integral */ @@ -300,6 +332,55 @@ int shifthz; volatile struct timeval time __attribute__((__aligned__(__alignof__(quad_t)))); volatile struct timeval mono_time; +/* + * The callout mechanism is based on the work of Adam M. Costello and + * George Varghese, published in a technical report entitled "Redesigning + * the BSD Callout and Timer Facilities", and Justin Gibbs's subsequent + * integration into FreeBSD, modified for NetBSD by Jason R. Thorpe. + * + * This version has been modified to keep the hash chains sorted. Since + * the hash chains are typically short, the overhead of this is minimal. + * Sorted hash chains reduce the number of comparisons in softclock(). + * This feature is enabled by defining CALLWHEEL_SORT. + * + * The original work on the data structures used in this implementation + * was published by G. Varghese and A. Lauck in the paper "Hashed and + * Hierarchical Timing Wheels: Data Structures for the Efficient + * Implementation of a Timer Facility" in the Proceedings of the 11th + * ACM Annual Symposium on Operating System Principles, Austin, Texas, + * November 1987. + */ +struct callout_queue *callwheel; +int callwheelsize, callwheelbits, callwheelmask; + +static struct callout *nextsoftcheck; /* next callout to be checked */ + +#ifdef CALLWHEEL_STATS +int callwheel_collisions; /* number of hash collisions */ +int callwheel_maxlength; /* length of the longest hash chain */ +int *callwheel_sizes; /* per-bucket length count */ +u_int64_t callwheel_count; /* # callouts currently */ +u_int64_t callwheel_established; /* # callouts established */ +u_int64_t callwheel_fired; /* # callouts that fired */ +u_int64_t callwheel_disestablished; /* # callouts disestablished */ +u_int64_t callwheel_changed; /* # callouts changed */ +u_int64_t callwheel_softclocks; /* # times softclock() called */ +u_int64_t callwheel_softchecks; /* # checks per softclock() */ +u_int64_t callwheel_softempty; /* # empty buckets seen */ +#ifdef CALLWHEEL_SORT +u_int64_t callwheel_comparisons; /* # of comparisons on insert */ +#endif +#endif /* CALLWHEEL_STATS */ + +/* + * This value indicates the number of consecutive callouts that + * will be checked before we allow interrupts to have a chance + * again. + */ +#ifndef MAX_SOFTCLOCK_STEPS +#define MAX_SOFTCLOCK_STEPS 100 +#endif + /* * Initialize clock frequencies and start both clocks running. */ @@ -348,7 +429,10 @@ initclocks() panic("weird hz"); } if (fixtick == 0) { - /* give MD code a chance to set this to a better value; but, if it doesn't, we should.. */ + /* + * Give MD code a chance to set this to a better + * value; but, if it doesn't, we should. + */ fixtick = (1000000 - (hz*tick)); } #endif @@ -361,9 +445,8 @@ void hardclock(frame) register struct clockframe *frame; { - register struct callout *p1; register struct proc *p; - register int delta, needsoft; + register int delta; extern int tickdelta; extern long timedelta; #ifdef NTP @@ -371,25 +454,6 @@ hardclock(frame) register int ltemp; #endif - /* - * Update real-time timeout queue. - * At front of queue are some number of events which are ``due''. - * The time to these is <= 0 and if negative represents the - * number of ticks which have passed since it was supposed to happen. - * The rest of the q elements (times > 0) are events yet to happen, - * where the time for each is given as a delta from the previous. - * Decrementing just the first of these serves to decrement the time - * to all events. - */ - needsoft = 0; - for (p1 = calltodo.c_next; p1 != NULL; p1 = p1->c_next) { - if (--p1->c_time > 0) - break; - needsoft = 1; - if (p1->c_time == 0) - break; - } - p = curproc; if (p) { register struct pstats *pstats; @@ -421,7 +485,7 @@ hardclock(frame) * if we are still adjusting the time (see adjtime()), * ``tickdelta'' may also be added in. */ - ticks++; + hardclock_ticks++; delta = tick; #ifndef NTP @@ -714,17 +778,23 @@ hardclock(frame) * Process callouts at a very low cpu priority, so we don't keep the * relatively high clock interrupt priority any longer than necessary. */ - if (needsoft) { + if (TAILQ_FIRST(&callwheel[hardclock_ticks & callwheelmask]) != NULL) { if (CLKF_BASEPRI(frame)) { /* * Save the overhead of a software interrupt; - * it will happen as soon as we return, so do it now. + * it will happen as soon as we return, so do + * it now. + * + * NOTE: If we're at ``base priority'', softclock() + * was not already running. */ (void)spllowersoftclock(); softclock(); } else setsoftclock(); - } + } else if (softclock_running == 0 && + (softclock_ticks + 1) == hardclock_ticks) + softclock_ticks++; } /* @@ -735,61 +805,152 @@ hardclock(frame) void softclock() { - register struct callout *c; - register void *arg; - register void (*func) __P((void *)); - register int s; + struct callout_queue *bucket; + struct callout *c; + void (*func) __P((void *)); + void *arg; + int s, idx; +#ifndef CALLWHEEL_SORT + int steps = 0; +#endif s = splhigh(); - while ((c = calltodo.c_next) != NULL && c->c_time <= 0) { - func = c->c_func; - arg = c->c_arg; - calltodo.c_next = c->c_next; - c->c_next = callfree; - callfree = c; - splx(s); - (*func)(arg); - (void) splhigh(); + softclock_running = 1; + +#ifdef CALLWHEEL_STATS + callwheel_softclocks++; +#endif + + while (softclock_ticks != hardclock_ticks) { + softclock_ticks++; + idx = (int)(softclock_ticks & callwheelmask); + bucket = &callwheel[idx]; + c = TAILQ_FIRST(bucket); +#ifdef CALLWHEEL_STATS + if (c == NULL) + callwheel_softempty++; +#endif + while (c != NULL) { +#ifdef CALLWHEEL_STATS + callwheel_softchecks++; +#endif +#ifdef CALLWHEEL_SORT + if (c->c_time > hardclock_ticks) + break; + nextsoftcheck = TAILQ_NEXT(c, c_link); + TAILQ_REMOVE(bucket, c, c_link); +#ifdef CALLWHEEL_STATS + callwheel_sizes[idx]--; + callwheel_fired++; + callwheel_count--; +#endif + func = c->c_func; + arg = c->c_arg; + c->c_func = NULL; + c->c_flags &= ~CALLOUT_PENDING; + splx(s); + (*func)(arg); + (void) splhigh(); + c = nextsoftcheck; +#else /* CALLWHEEL_SORT */ + if (c->c_time != softclock_ticks) { + c = TAILQ_NEXT(c, c_link); + if (++steps >= MAX_SOFTCLOCK_STEPS) { + nextsoftcheck = c; + /* Give interrupts a chance. */ + splx(s); + (void) splhigh(); + c = nextsoftcheck; + steps = 0; + } + } else { + nextsoftcheck = TAILQ_NEXT(c, c_link); + TAILQ_REMOVE(bucket, c, c_link); +#ifdef CALLWHEEL_STATS + callwheel_sizes[idx]--; + callwheel_fired++; + callwheel_count--; +#endif + func = c->c_func; + arg = c->c_arg; + c->c_func = NULL; + c->c_flags &= ~CALLOUT_PENDING; + splx(s); + (*func)(arg); + (void) splhigh(); + steps = 0; + c = nextsoftcheck; + } +#endif /* CALLWHEEL_SORT */ + } } + nextsoftcheck = NULL; + softclock_running = 0; splx(s); } /* * callout_startup: * - * Initialize the callout freelist. + * Initialize the callout subsystem. Called from main(). + * + * This must be called before cpu_startup(), which calls + * allocsys(), which is what actually allocates the callwheel. */ void callout_startup() { - int i; - callfree = callout; - for (i = 1; i < ncallout; i++) - callout[i-1].c_next = &callout[i]; - callout[i-1].c_next = NULL; + for (callwheelsize = 1; callwheelsize < ncallout; callwheelsize <<= 1) + /* loop */ ; + callwheelmask = callwheelsize - 1; } /* - * timeout -- - * Execute a function after a specified length of time. + * callout_startup1: * - * untimeout -- - * Cancel previous timeout function call. - * - * See AT&T BCI Driver Reference Manual for specification. This - * implementation differs from that one in that no identification - * value is returned from timeout, rather, the original arguments - * to timeout are used to identify entries for untimeout. + * Initialize the callwheel buckets. */ void -timeout(ftn, arg, ticks) - void (*ftn) __P((void *)); - void *arg; - register int ticks; +callout_startup1() { - register struct callout *new, *p, *t; - register int s; + int i; + + for (i = 0; i < callwheelsize; i++) + TAILQ_INIT(&callwheel[i]); +} + +/* + * callout_init: + * + * Initialize a callout structure so that it can be used + * by callout_reset() and callout_stop(). + */ +void +callout_init(c) + struct callout *c; +{ + + memset(c, 0, sizeof(*c)); +} + +/* + * callout_reset: + * + * Establish or change a timeout. + */ +void +callout_reset(c, ticks, func, arg) + struct callout *c; + int ticks; + void (*func) __P((void *)); + void *arg; +{ + struct callout_queue *bucket; +#ifdef CALLWHEEL_SORT + struct callout *c0; +#endif + int s; if (ticks <= 0) ticks = 1; @@ -797,63 +958,137 @@ timeout(ftn, arg, ticks) /* Lock out the clock. */ s = splhigh(); - /* Fill in the next free callout structure. */ - if (callfree == NULL) - panic("timeout table full"); - new = callfree; - callfree = new->c_next; - new->c_arg = arg; - new->c_func = ftn; - /* - * The time for each event is stored as a difference from the time - * of the previous event on the queue. Walk the queue, correcting - * the ticks argument for queue entries passed. Correct the ticks - * value for the queue entry immediately after the insertion point - * as well. Watch out for negative c_time values; these represent - * overdue events. + * If this callout's timer is already running, cancel it + * before we modify it. */ - for (p = &calltodo; - (t = p->c_next) != NULL && ticks > t->c_time; p = t) - if (t->c_time > 0) - ticks -= t->c_time; - new->c_time = ticks; - if (t != NULL) - t->c_time -= ticks; + if (c->c_flags & CALLOUT_PENDING) { + callout_stop(c); +#ifdef CALLWHEEL_STATS + callwheel_changed++; +#endif + } - /* Insert the new entry into the queue. */ - p->c_next = new; - new->c_next = t; - splx(s); -} + c->c_arg = arg; + c->c_func = func; + c->c_flags = CALLOUT_ACTIVE | CALLOUT_PENDING; + c->c_time = hardclock_ticks + ticks; -void -untimeout(ftn, arg) - void (*ftn) __P((void *)); - void *arg; -{ - register struct callout *p, *t; - register int s; + bucket = &callwheel[c->c_time & callwheelmask]; - s = splhigh(); - for (p = &calltodo; (t = p->c_next) != NULL; p = t) - if (t->c_func == ftn && t->c_arg == arg) { - /* Increment next entry's tick count. */ - if (t->c_next && t->c_time > 0) - t->c_next->c_time += t->c_time; +#ifdef CALLWHEEL_STATS + if (TAILQ_FIRST(bucket) != NULL) + callwheel_collisions++; +#endif + +#ifdef CALLWHEEL_SORT + for (c0 = TAILQ_FIRST(bucket); c0 != NULL; + c0 = TAILQ_NEXT(c0, c_link)) { +#ifdef CALLWHEEL_STATS + callwheel_comparisons++; +#endif + if (c0->c_time < c->c_time) + continue; + TAILQ_INSERT_BEFORE(c0, c, c_link); + goto out; + } + TAILQ_INSERT_TAIL(bucket, c, c_link); + out: +#else /* CALLWHEEL_SORT */ + TAILQ_INSERT_TAIL(bucket, c, c_link); +#endif /* CALLWHEEL_SORT */ + +#ifdef CALLWHEEL_STATS + callwheel_count++; + callwheel_established++; + if (++callwheel_sizes[c->c_time & callwheelmask] > callwheel_maxlength) + callwheel_maxlength = + callwheel_sizes[c->c_time & callwheelmask]; +#endif - /* Move entry from callout queue to callfree queue. */ - p->c_next = t->c_next; - t->c_next = callfree; - callfree = t; - break; - } splx(s); } /* - * Compute number of hz until specified time. Used to - * compute third argument to timeout() from an absolute time. + * callout_stop: + * + * Disestablish a timeout. + */ +void +callout_stop(c) + struct callout *c; +{ + int s; + + /* Lock out the clock. */ + s = splhigh(); + + /* + * Don't attempt to delete a callout that's not on the queue. + */ + if ((c->c_flags & CALLOUT_PENDING) == 0) { + c->c_flags &= ~CALLOUT_ACTIVE; + splx(s); + return; + } + + c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); + + if (nextsoftcheck == c) + nextsoftcheck = TAILQ_NEXT(c, c_link); + + TAILQ_REMOVE(&callwheel[c->c_time & callwheelmask], c, c_link); +#ifdef CALLWHEEL_STATS + callwheel_count--; + callwheel_disestablished++; + callwheel_sizes[c->c_time & callwheelmask]--; +#endif + + c->c_func = NULL; + + splx(s); +} + +#ifdef CALLWHEEL_STATS +/* + * callout_showstats: + * + * Display callout statistics. Call it from DDB. + */ +void +callout_showstats() +{ + u_int64_t curticks; + int s; + + s = splclock(); + curticks = softclock_ticks; + splx(s); + + printf("Callwheel statistics:\n"); + printf("\tCallouts currently queued: %llu\n", callwheel_count); +#ifdef CALLWHEEL_SORT + printf("\tCallouts established: %llu, Comparisons: %llu\n", + callwheel_established, callwheel_comparisons); +#else + printf("\tCallouts established: %llu\n", callwheel_established); +#endif + printf("\tCallouts disestablished: %llu\n", callwheel_disestablished); + if (callwheel_changed != 0) + printf("\t\tOf those, %llu were changes\n", callwheel_changed); + printf("\tCallouts that fired: %llu\n", callwheel_fired); + printf("\tNumber of buckets: %d\n", callwheelsize); + printf("\tNumber of hash collisions: %d\n", callwheel_collisions); + printf("\tMaximum hash chain length: %d\n", callwheel_maxlength); + printf("\tSoftclocks: %llu, Softchecks: %llu\n", + callwheel_softclocks, callwheel_softchecks); + printf("\t\tEmpty buckets seen: %llu\n", callwheel_softempty); +} +#endif + +/* + * Compute number of hz until specified time. Used to compute second + * argument to callout_reset() from an absolute time. */ int hzto(tv) @@ -1369,4 +1604,3 @@ sysctl_clockrate(where, sizep) clkinfo.stathz = stathz ? stathz : hz; return (sysctl_rdstruct(where, sizep, NULL, &clkinfo, sizeof(clkinfo))); } - diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index d258c2491ff5..04e5d18b5f5d 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.74 1999/09/28 14:47:03 bouyer Exp $ */ +/* $NetBSD: kern_exit.c,v 1.75 2000/03/23 06:30:11 thorpej Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -176,7 +176,7 @@ exit1(p, rv) sigfillset(&p->p_sigignore); sigemptyset(&p->p_siglist); p->p_sigcheck = 0; - untimeout(realitexpire, (caddr_t)p); + callout_stop(&p->p_realit_ch); /* * Close open files and release open-file table. diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 1eea219546fc..384b9a8074c3 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.61 1999/07/22 21:08:31 thorpej Exp $ */ +/* $NetBSD: kern_fork.c,v 1.62 2000/03/23 06:30:11 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -319,6 +319,9 @@ again: LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling); LIST_INIT(&p2->p_children); + callout_init(&p2->p_realit_ch); + callout_init(&p2->p_tsleep_ch); + #ifdef KTRACE /* * Copy traceflag and tracefile if enabled. diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 5694306deef7..5d958a7bcaa4 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.67 1999/11/15 18:49:09 fvdl Exp $ */ +/* $NetBSD: kern_synch.c,v 1.68 2000/03/23 06:30:12 thorpej Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -82,6 +82,7 @@ #include #include +#include #include #include #include @@ -113,6 +114,9 @@ void endtsleep __P((void *)); __inline void awaken __P((struct proc *)); +struct callout roundrobin_ch = CALLOUT_INITIALIZER; +struct callout schedcpu_ch = CALLOUT_INITIALIZER; + /* * Force switch among equal priority processes every 100ms. */ @@ -123,7 +127,7 @@ roundrobin(arg) { need_resched(); - timeout(roundrobin, NULL, hz / 10); + callout_reset(&roundrobin_ch, hz / 10, roundrobin, NULL); } /* @@ -276,7 +280,7 @@ schedcpu(arg) proclist_unlock_read(); uvm_meter(); wakeup((caddr_t)&lbolt); - timeout(schedcpu, (void *)0, hz); + callout_reset(&schedcpu_ch, hz, schedcpu, NULL); } /* @@ -386,7 +390,7 @@ tsleep(ident, priority, wmesg, timo) *qp->sq_tailp = p; *(qp->sq_tailp = &p->p_forw) = 0; if (timo) - timeout(endtsleep, (void *)p, timo); + callout_reset(&p->p_tsleep_ch, timo, endtsleep, p); /* * We put ourselves on the sleep queue and start our timeout * before calling CURSIG, as we could stop there, and a wakeup @@ -431,7 +435,7 @@ resume: return (EWOULDBLOCK); } } else if (timo) - untimeout(endtsleep, (void *)p); + callout_stop(&p->p_tsleep_ch); if (catch && (sig != 0 || (sig = CURSIG(p)) != 0)) { #ifdef KTRACE if (KTRPOINT(p, KTR_CSW)) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 6bfd10e85c01..0942800f22d2 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.43 2000/02/16 12:36:19 itojun Exp $ */ +/* $NetBSD: kern_time.c,v 1.44 2000/03/23 06:30:12 thorpej Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -517,10 +517,11 @@ sys_setitimer(p, v, retval) return (EINVAL); s = splclock(); if (which == ITIMER_REAL) { - untimeout(realitexpire, p); + callout_stop(&p->p_realit_ch); if (timerisset(&aitv.it_value)) { timeradd(&aitv.it_value, &time, &aitv.it_value); - timeout(realitexpire, p, hzto(&aitv.it_value)); + callout_reset(&p->p_realit_ch, hzto(&aitv.it_value), + realitexpire, p); } p->p_realtimer = aitv; } else @@ -555,8 +556,8 @@ realitexpire(arg) timeradd(&p->p_realtimer.it_value, &p->p_realtimer.it_interval, &p->p_realtimer.it_value); if (timercmp(&p->p_realtimer.it_value, &time, >)) { - timeout(realitexpire, p, - hzto(&p->p_realtimer.it_value)); + callout_reset(&p->p_realit_ch, + hzto(&p->p_realtimer.it_value), realitexpire, p); splx(s); return; } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 222372f748c2..6fd2183ff55d 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.115 1999/07/24 15:10:02 tron Exp $ */ +/* $NetBSD: tty.c,v 1.116 2000/03/23 06:30:12 thorpej Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1991, 1993 @@ -1528,8 +1528,8 @@ ttycheckoutq(tp, wait) splx(s); return (0); } - timeout((void (*)__P((void *)))wakeup, - (void *)&tp->t_outq, hz); + callout_reset(&tp->t_outq_ch, hz, + (void (*)__P((void *)))wakeup, &tp->t_outq); SET(tp->t_state, TS_ASLEEP); error = tsleep(&tp->t_outq, (PZERO - 1) | PCATCH, "ttckoutq", 0); @@ -2182,6 +2182,8 @@ ttymalloc() tp = pool_get(&tty_pool, PR_WAITOK); memset(tp, 0, sizeof(*tp)); + callout_init(&tp->t_outq_ch); + callout_init(&tp->t_rstrt_ch); /* XXX: default to 1024 chars for now */ clalloc(&tp->t_rawq, 1024, 1); clalloc(&tp->t_canq, 1024, 1); @@ -2201,6 +2203,8 @@ ttyfree(tp) struct tty *tp; { + callout_stop(&tp->t_outq_ch); + callout_stop(&tp->t_rstrt_ch); clfree(&tp->t_rawq); clfree(&tp->t_canq); clfree(&tp->t_outq); diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index b29ab7ab4989..e36751254f62 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_domain.c,v 1.29 2000/02/06 02:54:16 thorpej Exp $ */ +/* $NetBSD: uipc_domain.c,v 1.30 2000/03/23 06:30:13 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,8 @@ void pffasttimo __P((void *)); void pfslowtimo __P((void *)); +struct callout pffasttimo_ch, pfslowtimo_ch; + /* * Current time values for fast and slow timeouts. We can use u_int * relatively safely. The fast timer will roll over in 27 years and @@ -128,8 +131,12 @@ domaininit() max_linkhdr = 16; max_hdr = max_linkhdr + max_protohdr; max_datalen = MHLEN - max_hdr; - timeout(pffasttimo, NULL, 1); - timeout(pfslowtimo, NULL, 1); + + callout_init(&pffasttimo_ch); + callout_init(&pfslowtimo_ch); + + callout_reset(&pffasttimo_ch, 1, pffasttimo, NULL); + callout_reset(&pfslowtimo_ch, 1, pfslowtimo, NULL); } struct domain * @@ -269,7 +276,7 @@ pfslowtimo(arg) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_slowtimo) (*pr->pr_slowtimo)(); - timeout(pfslowtimo, NULL, hz/2); + callout_reset(&pfslowtimo_ch, hz / 2, pfslowtimo, NULL); } void @@ -285,5 +292,5 @@ pffasttimo(arg) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_fasttimo) (*pr->pr_fasttimo)(); - timeout(pffasttimo, NULL, hz/5); + callout_reset(&pffasttimo_ch, hz / 5, pffasttimo, NULL); } diff --git a/sys/sys/callout.h b/sys/sys/callout.h index 7ecb3434d541..c74885020dde 100644 --- a/sys/sys/callout.h +++ b/sys/sys/callout.h @@ -1,4 +1,41 @@ -/* $NetBSD: callout.h,v 1.12 2000/01/19 20:05:51 thorpej Exp $ */ +/* $NetBSD: callout.h,v 1.13 2000/03/23 06:31:51 thorpej Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ /*- * Copyright (c) 1990, 1993 @@ -42,18 +79,46 @@ #ifndef _SYS_CALLOUT_H_ #define _SYS_CALLOUT_H_ +#include + +TAILQ_HEAD(callout_queue, callout); + struct callout { - struct callout *c_next; /* next callout in queue */ - void *c_arg; /* function argument */ - void (*c_func) __P((void *)); /* function to call */ - int c_time; /* ticks to the event */ + TAILQ_ENTRY(callout) c_link; + u_int64_t c_time; /* when callout fires */ + void *c_arg; /* function argument */ + void (*c_func) __P((void *));/* functiuon to call */ + int c_flags; /* state of this entry */ }; -#ifdef _KERNEL -struct callout *callfree, *callout, calltodo; -int ncallout; +#define CALLOUT_ACTIVE 0x0001 /* callout is active */ +#define CALLOUT_PENDING 0x0002 /* callout time has not yet arrived */ -void callout_startup __P((void)); +#define CALLOUT_INITIALIZER { { NULL, NULL }, 0, NULL, NULL, 0 } + +#ifdef _KERNEL +extern struct callout_queue *callwheel; +extern int callwheelsize, callwheelbits, callwheelmask; +extern int ncallout; + +#ifdef CALLWHEEL_STATS +extern int *callwheel_sizes; /* for allocsys() */ #endif +void callout_startup __P((void)); +void callout_startup1 __P((void)); +void callout_init __P((struct callout *)); +void callout_reset __P((struct callout *, int, void (*)(void *), void *)); +void callout_stop __P((struct callout *)); +#ifdef CALLWHEEL_STATS +void callout_showstats __P((void)); +#endif + +#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) +#define callout_pending(c) ((c)->c_flags & CALLOUT_PENDING) +#define callout_expired(c) (callout_pending((c)) == 0) + +#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) +#endif /* _KERNEL */ + #endif /* !_SYS_CALLOUT_H_ */ diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index 71ae86bc85fc..eac82f599ff3 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -1,4 +1,4 @@ -/* $NetBSD: kernel.h,v 1.15 1999/09/17 20:09:07 thorpej Exp $ */ +/* $NetBSD: kernel.h,v 1.16 2000/03/23 06:31:51 thorpej Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -68,4 +68,17 @@ extern int stathz; /* statistics clock's frequency */ extern int profhz; /* profiling clock's frequency */ extern int lbolt; /* once a second sleep address */ +/* + * These globals indicate the number of times hardlock() has ticked, + * and the successive attempt of softclock() to catch up with it. These + * are large unsigned numbers so that arithmetic can be performed on them + * with no reasonable worry about an overflow occurring (we get over 500 + * million years with this). + * + * IMPORTANT NOTE: you *must* be at splclock() in order to read both + * hardclock_ticks and softclock_ticks. This is because the 64-bit + * quantities may not be readable in an atomic fashion on all CPU types. + */ +extern u_int64_t hardclock_ticks, softclock_ticks; + #endif /* _SYS_KERNEL_H_ */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b21474837261..82e1ea9fb4f1 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.86 2000/02/11 19:22:54 thorpej Exp $ */ +/* $NetBSD: proc.h,v 1.87 2000/03/23 06:31:51 thorpej Exp $ */ /*- * Copyright (c) 1986, 1989, 1991, 1993 @@ -53,6 +53,7 @@ #include /* Machine-dependent proc substruct. */ #include #include +#include /* * One structure allocated per session. @@ -156,10 +157,12 @@ struct proc { int p_cpticks; /* Ticks of cpu time. */ fixpt_t p_pctcpu; /* %cpu for this process during p_swtime */ void *p_wchan; /* Sleep address. */ + struct callout p_tsleep_ch;/* callout for tsleep */ const char *p_wmesg; /* Reason for sleep. */ u_int p_swtime; /* Time swapped in or out. */ u_int p_slptime; /* Time since last blocked. */ + struct callout p_realit_ch; /* real time callout */ struct itimerval p_realtimer; /* Alarm timer. */ struct timeval p_rtime; /* Real time. */ u_quad_t p_uticks; /* Statclock hits in user mode. */ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 842c46daf100..3c515941db86 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $NetBSD: systm.h,v 1.104 2000/03/16 17:19:54 jdolecek Exp $ */ +/* $NetBSD: systm.h,v 1.105 2000/03/23 06:31:52 thorpej Exp $ */ /*- * Copyright (c) 1982, 1988, 1991, 1993 @@ -221,8 +221,6 @@ long fuword __P((const void *)); long fuiword __P((const void *)); int hzto __P((struct timeval *tv)); -void timeout __P((void (*func)(void *), void *arg, int ticks)); -void untimeout __P((void (*func)(void *), void *arg)); void realitexpire __P((void *)); void hardclock __P((struct clockframe *frame)); diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 04fa6ea618a0..ab44d3e6bbb2 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -1,4 +1,4 @@ -/* $NetBSD: tty.h,v 1.47 1999/04/30 05:29:20 cgd Exp $ */ +/* $NetBSD: tty.h,v 1.48 2000/03/23 06:31:52 thorpej Exp $ */ /*- * Copyright (c) 1982, 1986, 1993 @@ -46,6 +46,7 @@ #include #include /* For struct selinfo. */ #include +#include /* * Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have @@ -79,6 +80,8 @@ struct tty { struct clist t_canq; /* Device canonical queue. */ long t_cancc; /* Canonical queue statistics. */ struct clist t_outq; /* Device output queue. */ + struct callout t_outq_ch; /* for ttycheckoutq() */ + struct callout t_rstrt_ch; /* for delayed output start */ long t_outcc; /* Output queue statistics. */ u_char t_line; /* Interface to device drivers. */ dev_t t_dev; /* Device. */