Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/kern Pull up revisions 1.71, 1.73 (requested by he):



details:   https://anonhg.NetBSD.org/src/rev/da7ed11de27d
branches:  netbsd-1-5
changeset: 491649:da7ed11de27d
user:      he <he%NetBSD.org@localhost>
date:      Sun May 06 15:08:22 2001 +0000

description:
Pull up revisions 1.71,1.73 (requested by he):
  Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
  PWR_SOFTRESUME.  Apm calls powerhook with the values in normal interrupt
  priority level while others are protected with splhigh().

diffstat:

 sys/kern/kern_subr.c |  37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diffs (82 lines):

diff -r 3f4fc42ebf8c -r da7ed11de27d sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c      Sun May 06 15:08:02 2001 +0000
+++ b/sys/kern/kern_subr.c      Sun May 06 15:08:22 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_subr.c,v 1.70.2.1 2001/03/30 21:46:40 he Exp $    */
+/*     $NetBSD: kern_subr.c,v 1.70.2.2 2001/05/06 15:08:22 he Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -336,15 +336,20 @@
 
 /*
  * "Power hook" types, functions, and variables.
+ * The list of power hooks is kept ordered with the last registered hook
+ * first.
+ * When running the hooks on power down the hooks are called in reverse
+ * registration order, when powering up in registration order.
  */
 
 struct powerhook_desc {
-       LIST_ENTRY(powerhook_desc) sfd_list;
+       CIRCLEQ_ENTRY(powerhook_desc) sfd_list;
        void    (*sfd_fn) __P((int, void *));
        void    *sfd_arg;
 };
 
-LIST_HEAD(, powerhook_desc) powerhook_list;
+CIRCLEQ_HEAD(, powerhook_desc) powerhook_list = 
+       CIRCLEQ_HEAD_INITIALIZER(powerhook_list);
 
 void *
 powerhook_establish(fn, arg)
@@ -360,7 +365,7 @@
 
        ndp->sfd_fn = fn;
        ndp->sfd_arg = arg;
-       LIST_INSERT_HEAD(&powerhook_list, ndp, sfd_list);
+       CIRCLEQ_INSERT_HEAD(&powerhook_list, ndp, sfd_list);
 
        return (ndp);
 }
@@ -372,15 +377,15 @@
 #ifdef DIAGNOSTIC
        struct powerhook_desc *dp;
 
-       for (dp = powerhook_list.lh_first; dp != NULL;
-           dp = dp->sfd_list.le_next)
+       CIRCLEQ_FOREACH(dp, &powerhook_list, sfd_list)
                 if (dp == vhook)
-                       break;
-       if (dp == NULL)
-               panic("powerhook_disestablish: hook not established");
+                       goto found;
+       panic("powerhook_disestablish: hook not established");
+ found:
 #endif
 
-       LIST_REMOVE((struct powerhook_desc *)vhook, sfd_list);
+       CIRCLEQ_REMOVE(&powerhook_list, (struct powerhook_desc *)vhook,
+           sfd_list);
        free(vhook, M_DEVBUF);
 }
 
@@ -393,10 +398,14 @@
 {
        struct powerhook_desc *dp;
 
-       for (dp = LIST_FIRST(&powerhook_list); 
-            dp != NULL; 
-            dp = LIST_NEXT(dp, sfd_list)) {
-               (*dp->sfd_fn)(why, dp->sfd_arg);
+       if (why == PWR_RESUME || why == PWR_SOFTRESUME) {
+               CIRCLEQ_FOREACH_REVERSE(dp, &powerhook_list, sfd_list) {
+                       (*dp->sfd_fn)(why, dp->sfd_arg);
+               }
+       } else {
+               CIRCLEQ_FOREACH(dp, &powerhook_list, sfd_list) {
+                       (*dp->sfd_fn)(why, dp->sfd_arg);
+               }
        }
 }
 



Home | Main Index | Thread Index | Old Index