diff options
author | 2000-10-18 16:53:01 +0000 | |
---|---|---|
committer | 2000-10-18 16:53:01 +0000 | |
commit | 5e4aa0e8e5bf70c35a368c544a406d8502d75f42 (patch) | |
tree | 927f147530b54e8e9c4cbc32d5710c83955509f0 | |
parent | various cleanups (diff) | |
download | wireguard-openbsd-5e4aa0e8e5bf70c35a368c544a406d8502d75f42.tar.xz wireguard-openbsd-5e4aa0e8e5bf70c35a368c544a406d8502d75f42.zip |
if periodic checks return errors, stop doing so. This is a workaround for
some other apm bug that happens on the SuperMicro DL3 (ServerWorks-based)
-rw-r--r-- | sys/arch/i386/i386/apm.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index 5f45181ed11..8cebfbce419 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.40 2000/07/26 03:39:45 mickey Exp $ */ +/* $OpenBSD: apm.c,v 1.41 2000/10/18 16:53:01 deraadt Exp $ */ /*- * Copyright (c) 1998-2000 Michael Shalayeff. All rights reserved. @@ -162,7 +162,7 @@ int apmcall __P((u_int, u_int, struct apmregs *)); void apm_power_print __P((struct apm_softc *, struct apmregs *)); void apm_handle_event __P((struct apm_softc *, struct apmregs *)); void apm_set_ver __P((struct apm_softc *)); -void apm_periodic_check __P((struct apm_softc *)); +int apm_periodic_check __P((struct apm_softc *)); void apm_thread_create __P((void *v)); void apm_thread __P((void *)); void apm_disconnect __P((struct apm_softc *)); @@ -233,6 +233,7 @@ apm_perror(str, regs) printf("apm0: APM %s: %s (%d)\n", str, apm_err_translate(APM_ERR_CODE(regs)), APM_ERR_CODE(regs)); + delay(1000000); apmerrors++; } @@ -504,11 +505,12 @@ apm_handle_event(sc, regs) } } -void +int apm_periodic_check(sc) struct apm_softc *sc; { struct apmregs regs; + int ret = 0; if (apm_op_inprog) apm_set_powstate(APM_DEV_ALLDEVS, APM_LASTREQ_INPROG); @@ -518,7 +520,10 @@ apm_periodic_check(sc) /* i think some bioses actually combine the error codes */ if (!(APM_ERR_CODE(®s) & APM_ERR_NOEVENTS)) - apm_perror("get event", ®s); + apm_perror("periodic get event", ®s); + + if (apm_error || APM_ERR_CODE(®s) == APM_ERR_NOTCONN) + ret = -1; if (apm_suspends /*|| (apm_battlow && apm_userstandbys)*/) { apm_op_inprog = 0; @@ -532,6 +537,7 @@ apm_periodic_check(sc) if (apm_resumes) apm_resumes--; + return (ret); } void @@ -702,7 +708,7 @@ apm_disconnect(sc) if (apmcall(APM_DISCONNECT, APM_DEV_APM_BIOS, ®s)) apm_perror("disconnect failed", ®s); else - printf("APM disconnected\n"); + printf("%s: disconnected\n", sc->sc_dev.dv_xname); } int @@ -852,9 +858,11 @@ apmattach(parent, self, aux) lockinit(&sc->sc_lock, PWAIT, "apmlk", 0, 0); - apm_periodic_check(sc); - - kthread_create_deferred(apm_thread_create, sc); + if (apm_periodic_check(sc) == -1) { + apm_disconnect(sc); + apm_dobusy = apm_doidle = 0; + } else + kthread_create_deferred(apm_thread_create, sc); } else { dynamic_gdt[GAPM32CODE_SEL] = dynamic_gdt[GNULL_SEL]; dynamic_gdt[GAPM16CODE_SEL] = dynamic_gdt[GNULL_SEL]; @@ -883,7 +891,7 @@ apm_thread(v) for (;;) { APM_LOCK(sc); - apm_periodic_check(sc); + (void) apm_periodic_check(sc); APM_UNLOCK(sc); tsleep(&lbolt, PWAIT, "apmev", 0); } |