The following reply was made to PR kern/148367; it has been noted by GNATS.

From: Dmitry Pryanishnikov <[email protected]>
To: [email protected], [email protected]
Cc:  
Subject: Re: kern/148367: [syscons] [patch] Add loader tunable to override
 SC_HISTORY_SIZE
Date: Wed, 15 Dec 2010 23:39:21 +0200

 This is a multi-part message in MIME format.
 --------------000808020106000008070103
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 
 Hello!
 
    The patch has been updated for schistory.c,v 1.21.2.2 (current version in 
 RELENG_8).
 
 Sincerely, Dmitry
 -- 
 nic-hdl: LYNX-RIPE
 
 --------------000808020106000008070103
 Content-Type: text/plain;
  name="syscons-history_size.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="syscons-history_size.patch"
 
 --- sys/dev/syscons/syscons.h.orig     2010-08-23 14:33:35.837815000 +0300
 +++ sys/dev/syscons/syscons.h  2010-12-15 23:16:15.492041513 +0200
 @@ -573,6 +573,7 @@
  
  /* schistory.c */
  #ifndef SC_NO_HISTORY
 +void          sc_init_history(void);
  int           sc_alloc_history_buffer(scr_stat *scp, int lines,
                                        int prev_ysize, int wait);
  void          sc_free_history_buffer(scr_stat *scp, int prev_ysize);
 --- sys/dev/syscons/syscons.c.orig     2010-08-23 14:33:35.827279000 +0300
 +++ sys/dev/syscons/syscons.c  2010-12-15 23:16:15.494051860 +0200
 @@ -2726,8 +2726,12 @@
      int i;
  
      /* one time initialization */
 -    if (init_done == COLD)
 +    if (init_done == COLD) {
        sc_get_bios_values(&bios_value);
 +#ifndef SC_NO_HISTORY
 +      sc_init_history();
 +#endif
 +    }
      init_done = WARM;
  
      /*
 --- sys/dev/syscons/schistory.c.orig   2010-12-15 22:44:32.506598000 +0200
 +++ sys/dev/syscons/schistory.c        2010-12-15 23:16:15.494051860 +0200
 @@ -41,6 +41,7 @@
  #include <sys/tty.h>
  #include <sys/kernel.h>
  #include <sys/malloc.h>
 +#include <sys/sysctl.h>
  
  #if defined(__sparc64__) || defined(__powerpc__)
  #include <machine/sc_machdep.h>
 @@ -77,17 +78,37 @@
  static int            extra_history_size
                                = SC_MAX_HISTORY_SIZE - SC_HISTORY_SIZE*MAXCONS;
  
 +static int            sc_history_size = SC_HISTORY_SIZE;
 +
 +SYSCTL_DECL(_hw_syscons);
 +SYSCTL_INT(_hw_syscons, OID_AUTO, history_size, CTLFLAG_RDTUN, 
&sc_history_size, 0,
 +    "Number of history buffer lines");
 +
  /* local functions */
  static void copy_history(sc_vtb_t *from, sc_vtb_t *to);
  static void history_to_screen(scr_stat *scp);
  
 +/* tune history buffer size */
 +void
 +sc_init_history(void)
 +{
 +
 +      TUNABLE_INT_FETCH("hw.syscons.history_size", &sc_history_size);
 +      if (sc_history_size < ROW * 4)
 +          sc_history_size = ROW * 4;
 +      extra_history_size =
 +          ((sc_history_size * MAXCONS * MAXSC) > SC_MAX_HISTORY_SIZE ?
 +              sc_history_size * MAXCONS * MAXSC : SC_MAX_HISTORY_SIZE) -
 +                  sc_history_size * MAXCONS;
 +}
 +
  /* allocate a history buffer */
  int
  sc_alloc_history_buffer(scr_stat *scp, int lines, int prev_ysize, int wait)
  {
        /*
         * syscons unconditionally allocates buffers up to 
 -       * SC_HISTORY_SIZE lines or scp->ysize lines, whichever 
 +       * sc_history_size lines or scp->ysize lines, whichever 
         * is larger. A value greater than that is allowed, 
         * subject to extra_history_size.
         */
 @@ -98,7 +119,7 @@
        int delta;                              /* lines to put back */
  
        if (lines <= 0)
 -              lines = SC_HISTORY_SIZE;        /* use the default value */
 +              lines = sc_history_size;        /* use the default value */
  
        /* make it at least as large as the screen size */
        lines = imax(lines, scp->ysize);
 @@ -111,13 +132,13 @@
        delta = 0;
        if (prev_history) {
                cur_lines = sc_vtb_rows(history);
 -              min_lines = imax(SC_HISTORY_SIZE, prev_ysize);
 +              min_lines = imax(sc_history_size, prev_ysize);
                if (cur_lines > min_lines)
                        delta = cur_lines - min_lines;
        }
  
        /* lines up to min_lines are always allowed. */
 -      min_lines = imax(SC_HISTORY_SIZE, scp->ysize);
 +      min_lines = imax(sc_history_size, scp->ysize);
        if (lines > min_lines) {
                if (lines - min_lines > extra_history_size + delta) {
                        /* too many lines are requested */
 @@ -196,7 +217,7 @@
                return;
  
        cur_lines = sc_vtb_rows(history);
 -      min_lines = imax(SC_HISTORY_SIZE, prev_ysize);
 +      min_lines = imax(sc_history_size, prev_ysize);
        extra_history_size += (cur_lines > min_lines) ? 
                                  cur_lines - min_lines : 0;
  
 --- share/man/man4/syscons.4.orig      2010-03-02 03:56:55.000000000 +0200
 +++ share/man/man4/syscons.4   2010-12-15 23:16:15.495058710 +0200
 @@ -442,6 +442,20 @@
  for a keyboard device if it is not currently attached to one.
  Otherwise, the driver only probes for a keyboard once during bootup.
  .El
 +.Ss Loader Tunables
 +Tunables can be set at the
 +.Xr loader 8
 +prompt before booting the kernel or stored in
 +.Pa /boot/loader.conf .
 +Some of these tunables also have a matching
 +.Xr sysctl 8
 +entry for access after boot.
 +.Bl -tag -width indent
 +.It hw.syscons.history_size
 +Override the size of back scroll buffer (specified by the
 +.Dv SC_HISTORY_SIZE
 +option).
 +.El
  .Sh FILES
  .Bl -tag -width /usr/share/syscons/xxxxyyyyzzz -compact
  .It Pa /dev/console
 
 --------------000808020106000008070103--
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to