Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc Add `fb_is_console()', which is a helper func...



details:   https://anonhg.NetBSD.org/src/rev/6c9ec1b9559b
branches:  trunk
changeset: 483836:6c9ec1b9559b
user:      pk <pk%NetBSD.org@localhost>
date:      Sun Mar 19 13:48:44 2000 +0000

description:
Add `fb_is_console()', which is a helper function for frame buffer
device drivers used to decide whether or not to act as console output.

diffstat:

 sys/arch/sparc/dev/fb.c        |  42 +++++++++++++++++++++++++++++++++++++++++-
 sys/arch/sparc/include/fbvar.h |   3 ++-
 2 files changed, 43 insertions(+), 2 deletions(-)

diffs (80 lines):

diff -r fdf8abbae047 -r 6c9ec1b9559b sys/arch/sparc/dev/fb.c
--- a/sys/arch/sparc/dev/fb.c   Sun Mar 19 13:45:23 2000 +0000
+++ b/sys/arch/sparc/dev/fb.c   Sun Mar 19 13:48:44 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fb.c,v 1.42 1999/08/26 20:50:08 thorpej Exp $ */
+/*     $NetBSD: fb.c,v 1.43 2000/03/19 13:48:45 pk Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -62,6 +62,7 @@
 #include <machine/conf.h>
 #include <machine/eeprom.h>
 #include <sparc/dev/pfourreg.h>
+#include <sparc/dev/cons.h>
 
 static struct fbdevice *devfb;
 
@@ -73,6 +74,45 @@
                (*devfb->fb_driver->fbd_unblank)(devfb->fb_device);
 }
 
+/*
+ * Helper function for frame buffer devices. Decides whether
+ * the device can be the console output device according to
+ * PROM info. The result from this function may not be conclusive
+ * on machines with old PROMs; in that case, drivers should consult
+ * other sources of configuration information (e.g. EEPROM entries).
+ */
+int
+fb_is_console(node)
+       int node;
+{
+       int fbnode;
+
+       switch (prom_version()) {
+       case PROM_OLDMON:
+               /* `node' is not valid; just check for any fb device */
+               return (prom_stdout() == PROMDEV_SCREEN);
+
+       case PROM_OBP_V0:
+               /*
+                * Prefer the `fb' property on the root node.
+                * Fall back on prom_stdout() cookie if not present.
+                */
+               fbnode = getpropint(findroot(), "fb", 0);
+               if (fbnode == 0)
+                       return (prom_stdout() == PROMDEV_SCREEN);
+               else
+                       return (node == fbnode);
+
+       case PROM_OBP_V2:
+       case PROM_OBP_V3:
+       case PROM_OPENFIRM:
+               /* Just match the nodes */
+               return (node == prom_stdout_node);
+       }
+
+       return (0);
+}
+
 void
 fb_attach(fb, isconsole)
        struct fbdevice *fb;
diff -r fdf8abbae047 -r 6c9ec1b9559b sys/arch/sparc/include/fbvar.h
--- a/sys/arch/sparc/include/fbvar.h    Sun Mar 19 13:45:23 2000 +0000
+++ b/sys/arch/sparc/include/fbvar.h    Sun Mar 19 13:48:44 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fbvar.h,v 1.11 1999/04/13 18:45:41 ad Exp $ */
+/*     $NetBSD: fbvar.h,v 1.12 2000/03/19 13:48:44 pk Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -100,6 +100,7 @@
 void   fb_attach __P((struct fbdevice *, int));
 void   fb_setsize_obp __P((struct fbdevice *, int, int, int, int));
 void   fb_setsize_eeprom __P((struct fbdevice *, int, int, int));
+int    fb_is_console __P((int));
 #ifdef RASTERCONSOLE
 void   fbrcons_init __P((struct fbdevice *));
 int    fbrcons_rows __P((void));



Home | Main Index | Thread Index | Old Index