Subject: /dev/fb changes
To: None <port-sparc@netbsd.org>
From: Matt Thomas <matt@3am-software.com>
List: port-sparc
Date: 08/04/1999 20:53:43
I have some changes to /dev/fb which makes the display nicer
on the Tadpole SPARCbook 3 with raster console.  

The changes are clearing the entire screen, resetting the colormap,
(these were in p9100.c and were because of the position of text
and colormap on the tadpole) then printing out the contents of the message 
buffer (e.g. all boot messages up to the point of attachment), and 
then continuing on.

On shutdown, the p9100 restores the colormap that the OpenProm
expects.

Would anyone object to myself committing these changes?

===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc/dev/fb.c,v
retrieving revision 1.39
diff -u -1 -0 -r1.39 fb.c
--- fb.c        1999/06/02 23:24:00     1.39
+++ fb.c        1999/08/05 03:54:35
@@ -47,30 +47,36 @@
  /*
   * /dev/fb (indirect frame buffer driver).  This is gross; we should
   * just build cdevsw[] dynamically.
   */
  
  #include <sys/param.h>
  #include <sys/systm.h>
  #include <sys/device.h>
  #include <sys/proc.h>
  #include <sys/conf.h>
+#ifdef RASTERCONSOLE
+#include <sys/msgbuf.h>
+#endif
  
  #include <machine/autoconf.h>
  #include <machine/fbio.h>
  #include <machine/kbd.h>
  #include <machine/fbvar.h>
  #include <machine/conf.h>
  #include <machine/eeprom.h>
  #include <sparc/dev/pfourreg.h>
  
  static struct fbdevice *devfb;
+#ifdef RASTERCONSOLE
+static void fbrcons_puts __P((struct fbdevice *, unsigned char *, int len));
+#endif
  
  void
  fb_unblank()
  {
  
         if (devfb)
                 (*devfb->fb_driver->fbd_unblank)(devfb->fb_device);
  }
  
  void
@@ -421,24 +427,64 @@
                 rc->rc_col = *col;
         }
  #endif
         rc->rc_ops = &ri->ri_ops;
         rc->rc_cookie = ri;
         rc->rc_bell = fb_bell;
         rc->rc_maxcol = ri->ri_cols;
         rc->rc_maxrow = ri->ri_rows;
         rc->rc_width = ri->ri_emuwidth;
         rc->rc_height = ri->ri_emuheight;
-       rcons_init(rc, 0);
+       rcons_init(rc, msgbufenabled && msgbufp->msg_magic == MSG_MAGIC);
  
         /* Hook up virtual console */
         v_putc = rcons_cnputc;
+
+       /* Repaint the screen with the current contents of the message buffer
+        */
+       if (msgbufenabled && msgbufp->msg_magic == MSG_MAGIC) {
+               long l = msgbufp->msg_bufx - msgbufp->msg_bufr;
+               if (l > 0) {
+                       fbrcons_puts(fb, (u_char *) &msgbufp->msg_bufc[msgbufp->msg_bufr], l);
+               } else if (l < 0) {
+                       fbrcons_puts(fb, (u_char *) &msgbufp->msg_bufc[msgbufp->msg_bufr],
+                                  msgbufp->msg_bufs - msgbufp->msg_bufr);
+                       fbrcons_puts(fb, (u_char *) msgbufp->msg_bufc, l + msgbufp->msg_bufr);
+               }
+       }
+}
+
+static void
+fbrcons_puts(fb, str, len)
+       struct fbdevice *fb;
+       unsigned char *str;
+       int len;
+{
+       struct rconsole *rc = &fb->fb_rcons;
+       long i, n;
+
+       i = n = 0;
+       while (n < len) {
+               if (str[n++] != '\n') {
+                       continue;
+               }
+               if (n > 1) {
+                       rcons_puts(rc, str, n - 1);
+               }
+               rcons_puts(rc, "\r\n", 2);
+               str += n;
+               len -= n;
+               i = n = 0;
+       }
+       if (n > 0) {
+               rcons_puts(rc, str, n);
+       }
  }
  
  int
  fbrcons_rows()
  {
         return (devfb ? devfb->fb_rcons.rc_maxrow : 0);
  }
  
  int
  fbrcons_cols()
-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt/
Cupertino, CA             Disclaimer: I avow all knowledge of this message