From: mickey Date: Wed, 29 Mar 2000 23:11:06 +0000 (+0000) Subject: timeout-driven heartbeat. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0f5a20828e553cddc69818a7e14e03665c113f05;p=openbsd timeout-driven heartbeat. right thing would be to pass beat count as an argument to timeout routine (casted to (void *)) avoiding static counter, but doing timeout_set() every timeout_add() sounds kinda uncool. well, pondering in the struct timeout guts would be even more ugly. --- diff --git a/sys/arch/hppa/dev/clock.c b/sys/arch/hppa/dev/clock.c index b5d8cb20539..fe429828ea8 100644 --- a/sys/arch/hppa/dev/clock.c +++ b/sys/arch/hppa/dev/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.8 2000/02/09 05:51:21 mickey Exp $ */ +/* $OpenBSD: clock.c,v 1.9 2000/03/29 23:11:06 mickey Exp $ */ /* * Copyright (c) 1998,1999 Michael Shalayeff @@ -72,13 +72,6 @@ clock_intr (v) void *v; { struct trapframe *frame = v; -#ifdef USELEDS - static u_int hbcnt = 0; - - if (!(hbcnt % (hz / 8)) && ((hbcnt / (hz / 8)) & 7) < 4) - ledctl(0, 0, PALED_HEARTBEAT); - hbcnt++; -#endif /* printf ("clock int 0x%x @ 0x%x for %p\n", t, frame->tf_iioq_head, curproc); */ diff --git a/sys/arch/hppa/hppa/autoconf.c b/sys/arch/hppa/hppa/autoconf.c index fd6fe095c2f..9f54f415159 100644 --- a/sys/arch/hppa/hppa/autoconf.c +++ b/sys/arch/hppa/hppa/autoconf.c @@ -1,7 +1,7 @@ -/* $OpenBSD: autoconf.c,v 1.7 1999/11/25 18:31:53 mickey Exp $ */ +/* $OpenBSD: autoconf.c,v 1.8 2000/03/29 23:11:12 mickey Exp $ */ /* - * Copyright (c) 1998 Michael Shalayeff + * Copyright (c) 1998-2000 Michael Shalayeff * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,15 @@ static int findblkmajor __P((struct device *dv)); void (*cold_hook) __P((void)); /* see below */ register_t kpsw = PSW_Q | PSW_P | PSW_C | PSW_D; +/* + * LED blinking thing + */ +#ifdef USELEDS +struct timeout heartbeat_tmo; +void heartbeat __P((void *)); +extern int hz; +#endif + /* * configure: * called at boot time, configure all devices on system @@ -94,8 +104,43 @@ configure() cold = 0; if (cold_hook) (*cold_hook)(); + +#ifdef USELEDS + timeout_set(&heartbeat_tmo, heartbeat, NULL); + timeout_add(&heartbeat_tmo, hz / 8); +#endif } +#ifdef USELEDS +/* + * turn the heartbeat alive. + * right thing would be to pass counter to each subsequent timeout + * as an argument to heartbeat() incrementing every turn, + * i.e. avoiding the static hbcnt, but doing timeout_set() on each + * timeout_add() sounds ugly, guts of struct timeout looks ugly + * to ponder in even more. + */ +void +heartbeat(v) + void *v; +{ + static u_int hbcnt = 0; + + /* + * do this: + * + * |~| |~| + * _| |_| |_,_,_,_ + * 0 1 2 3 4 6 7 + */ + if (hbcnt % 8 < 4) + ledctl(0, 0, PALED_HEARTBEAT); + hbcnt++; + + timeout_add(&heartbeat_tmo, hz / 8); +} +#endif + /* * Configure swap space and related parameters. */ @@ -144,7 +189,7 @@ dumpconf() if (nblks <= ctod(1)) goto bad; dumpblks = cpu_dumpsize(); - if (dumpblks < 0) + if (dumpblks < 0) goto bad; dumpblks += ctod(physmem); diff --git a/sys/arch/hppa/include/cpufunc.h b/sys/arch/hppa/include/cpufunc.h index 4533d86af5e..9832f01e9a7 100644 --- a/sys/arch/hppa/include/cpufunc.h +++ b/sys/arch/hppa/include/cpufunc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpufunc.h,v 1.14 2000/02/09 05:10:10 mickey Exp $ */ +/* $OpenBSD: cpufunc.h,v 1.15 2000/03/29 23:11:12 mickey Exp $ */ /* * Copyright (c) 1998 Michael Shalayeff @@ -259,7 +259,6 @@ void ptlball __P((void)); int btlb_insert __P((pa_space_t space, vaddr_t va, paddr_t pa, vsize_t *lenp, u_int prot)); hppa_hpa_t cpu_gethpa __P((int n)); -void heartbeat __P((int on)); #endif #endif /* _MACHINE_CPUFUNC_H_ */