Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips/vr CONFIG_HOOK_GET support for get current ...



details:   https://anonhg.NetBSD.org/src/rev/543a289c5f6c
branches:  trunk
changeset: 507587:543a289c5f6c
user:      sato <sato%NetBSD.org@localhost>
date:      Mon Mar 26 08:57:02 2001 +0000

description:
CONFIG_HOOK_GET support for get current port status.

diffstat:

 sys/arch/hpcmips/vr/button_vrgiu.c |  29 ++++++++++++++++++++++++++++-
 sys/arch/hpcmips/vr/pwctl_vrgiu.c  |  28 ++++++++++++++++++++++++++--
 2 files changed, 54 insertions(+), 3 deletions(-)

diffs (128 lines):

diff -r 451260852bbe -r 543a289c5f6c sys/arch/hpcmips/vr/button_vrgiu.c
--- a/sys/arch/hpcmips/vr/button_vrgiu.c        Mon Mar 26 06:47:34 2001 +0000
+++ b/sys/arch/hpcmips/vr/button_vrgiu.c        Mon Mar 26 08:57:02 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: button_vrgiu.c,v 1.2 2000/02/10 08:37:07 sato Exp $    */
+/*     $NetBSD: button_vrgiu.c,v 1.3 2001/03/26 08:57:02 sato Exp $    */
 
 /*-
  * Copyright (c) 1999
@@ -58,6 +58,7 @@
        long sc_id;
        int sc_active;
        config_hook_tag sc_hook_tag;
+       config_hook_tag sc_ghook_tag;
 };
 
 static int     button_vrgiu_match __P((struct device *, struct cfdata *,
@@ -65,6 +66,8 @@
 static void    button_vrgiu_attach __P((struct device *, struct device *,
                                        void *));
 static int     button_vrgiu_intr __P((void*));
+static int     button_vrgiu_state __P((void *ctx, int type, long id,
+                                     void *msg));
 
 struct cfattach button_vrgiu_ca = {
        sizeof(struct button_vrgiu_softc), button_vrgiu_match, button_vrgiu_attach
@@ -135,10 +138,34 @@
                sc->sc_gf->gf_intr_establish(sc->sc_gc, sc->sc_port,
                                             mode, IPL_TTY,
                                             button_vrgiu_intr, sc);
+       sc->sc_ghook_tag = config_hook(CONFIG_HOOK_GET,
+                                      sc->sc_id,
+                                      CONFIG_HOOK_SHARE,
+                                      button_vrgiu_state,
+                                      sc);     
        printf("\n");
 }
 
 int
+button_vrgiu_state(ctx, type, id, msg)
+       void *ctx;
+       int type;
+       long id;
+       void *msg;
+{
+       struct button_vrgiu_softc *sc = ctx;
+
+       if (type != CONFIG_HOOK_GET || id != sc->sc_id)
+               return 1;
+
+       if (CONFIG_HOOK_VALUEP(msg))
+               return 1;
+
+       *(int*)msg = (sc->sc_gf->gf_portread(sc->sc_gc, sc->sc_port) == sc->sc_active);
+       return 0;
+}
+
+int
 button_vrgiu_intr(ctx)
        void *ctx;
 {
diff -r 451260852bbe -r 543a289c5f6c sys/arch/hpcmips/vr/pwctl_vrgiu.c
--- a/sys/arch/hpcmips/vr/pwctl_vrgiu.c Mon Mar 26 06:47:34 2001 +0000
+++ b/sys/arch/hpcmips/vr/pwctl_vrgiu.c Mon Mar 26 08:57:02 2001 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: pwctl_vrgiu.c,v 1.5 2000/10/17 11:37:20 sato Exp $     */
+/*     $NetBSD: pwctl_vrgiu.c,v 1.6 2001/03/26 08:57:02 sato Exp $     */
 
 /*-
  * Copyright (c) 1999
  *         Shin Takemura and PocketBSD Project. All rights reserved.
- * Copyright (c) 2000
+ * Copyright (c) 2000,2001
  *         SATO Kazumi. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,6 +69,7 @@
        int sc_on, sc_off;
        config_hook_tag sc_hook_tag;
        config_hook_tag sc_hook_hardpower;
+       config_hook_tag sc_ghook_tag;
        int sc_save;
        int sc_initvalue;
 };
@@ -79,6 +80,8 @@
                                        void *));
 static int     pwctl_vrgiu_hook __P((void *ctx, int type, long id,
                                      void *msg));
+static int     pwctl_vrgiu_ghook __P((void *ctx, int type, long id,
+                                     void *msg));
 int    pwctl_vrgiu_hardpower __P((void *, int, long, void *));
 
 struct cfattach pwctl_vrgiu_ca = {
@@ -135,6 +138,9 @@
                sc->sc_hook_tag = config_hook(CONFIG_HOOK_POWERCONTROL,
                                              sc->sc_id, CONFIG_HOOK_SHARE,
                                              pwctl_vrgiu_hook, sc);
+               sc->sc_ghook_tag = config_hook(CONFIG_HOOK_GET,
+                                             sc->sc_id, CONFIG_HOOK_SHARE,
+                                             pwctl_vrgiu_ghook, sc);
                sc->sc_hook_hardpower = config_hook(CONFIG_HOOK_PMEVENT,
                                                CONFIG_HOOK_PMEVENT_HARDPOWER,
                                                CONFIG_HOOK_SHARE,
@@ -164,6 +170,24 @@
 }
 
 int
+pwctl_vrgiu_ghook(ctx, type, id, msg)
+       void *ctx;
+       int type;
+       long id;
+       void *msg;
+{
+       struct pwctl_vrgiu_softc *sc = ctx;
+
+       if (CONFIG_HOOK_VALUEP(msg))
+               return 1;
+
+       *(int*)msg = sc->sc_gf->gf_portread(sc->sc_gc, sc->sc_port) == sc->sc_on;
+       DPRINTF(("pwctl ghook: port %d %s(%d)", sc->sc_port,
+                *(int*)msg? "ON" : "OFF", *(int*)msg ? sc->sc_on : sc->sc_off));
+       return 0;
+}
+
+int
 pwctl_vrgiu_hardpower(ctx, type, id, msg)
        void *ctx;
        int type;



Home | Main Index | Thread Index | Old Index