From yensid@beach.aca.imsa.edu  Fri Apr 25 21:08:31 1997
Received: from beach.aca.imsa.edu (beach.aca.imsa.edu [143.195.65.9])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id VAA03359
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 25 Apr 1997 21:08:30 -0700 (PDT)
Received: (from yensid@localhost)
	by beach.aca.imsa.edu (8.8.5/8.8.5) id XAA11566;
	Fri, 25 Apr 1997 23:18:54 -0500 (CDT)
Message-Id: <199704260418.XAA11566@beach.aca.imsa.edu>
Date: Fri, 25 Apr 1997 23:18:54 -0500 (CDT)
From: yensid@imsa.edu
Reply-To: yensid@imsa.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: Pentium optimizations in default bootdisk breaks some 486's
X-Send-Pr-Version: 3.2

>Number:         3391
>Category:       kern
>Synopsis:       Pentium optimizations in default bootdisk breaks some 486's
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 25 21:10:01 PDT 1997
>Closed-Date:    Mon May 12 03:44:28 PDT 1997
>Last-Modified:  Mon May 12 03:48:13 PDT 1997
>Originator:     Don Schmidt
>Release:        FreeBSD 2.1.7-RELEASE i386
>Organization:
Illinois Math and Science Academy
>Environment:
	i486 w/AMD BIOS, 28M ram, Diamond Speedstar Pro (Cirrus GD5230 based)
	vesa video board

>Description:
	On all current boot disks, on certain 486's (mine, at least)
after the kernel is loaded, the screen characters turn into unreadable
gibberish in simply horrid shades of magenta and orange, leaving the
machine in a unusable state.  

>How-To-Repeat:
	Would seem to be repeatable only on specific configurations

>Fix:
	Removing support for I586_CPU in the bootdisk kernel would disable
the optimizations that are apparently causing the problems.
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.org, yensid@imsa.edu
Cc:  Subject: Re: kern/3391: Pentium optimizations in default bootdisk breaks some 486's
Date: Sat, 26 Apr 1997 16:49:45 +1000

 >>Release:        FreeBSD 2.1.7-RELEASE i386
 >>Environment:
 >	i486 w/AMD BIOS, 28M ram, Diamond Speedstar Pro (Cirrus GD5230 based)
 >	vesa video board
 >
 >>Description:
 >	On all current boot disks, on certain 486's (mine, at least)
 >after the kernel is loaded, the screen characters turn into unreadable
 >gibberish in simply horrid shades of magenta and orange, leaving the
 >machine in a unusable state.  
 
 This can't have anything to do with i586 optimizations.  There are no i586
 significant optimizations in 2.1.7.  There is one (insignificant) i586
 optimization -  not using the i486-optimized bzero,  There is one
 (insignificant) i586 pessimization - zeroing the TimeStampCounter every
 clock tick and never using things that depend on this.  The i586
 mizations are only used on i586's.
 
 Bruce

From: Don Schmidt <yensid@imsa.edu>
To: Bruce Evans <bde@zeta.org.au>
Cc: FreeBSD-gnats-submit@FreeBSD.org, yensid@imsa.edu
Subject: Re: kern/3391: Pentium optimizations in default bootdisk breaks some 486's 
Date: Sat, 26 Apr 1997 02:09:38 -0500

 In message <199704260649.QAA29155@godzilla.zeta.org.au>, Bruce Evans writes:
 >>
 >>>Description:
 >>	On all current boot disks, on certain 486's (mine, at least)
 >>after the kernel is loaded, the screen characters turn into unreadable
 >>gibberish in simply horrid shades of magenta and orange, leaving the
 >>machine in a unusable state.  
 >
 >This can't have anything to do with i586 optimizations.  There are no i586
 
 Actually, I think there was a version mix-up; I filed the problem report
 from a system running 2.1.7, I'm having this problem with 2.2 and later.
 Sorry 'bout that
 
 When I posed this problem to the general problems list, I received responses
 indicating that this was a problem with the 586 optimizations, and the
 source seems to agree:
 
 freebsd-src/sys/i386/isa/npx.c
 [...]
 int
 npxattach(dvp)
         struct isa_device *dvp;
 {
         /* The caller has printed "irq 13" for the npx_irq13 case. */
 [...]
 
 #ifdef I586_CPU
         if (cpu_class == CPUCLASS_586 && npx_ex16) {
                 if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
                         bcopy_vector = i586_bcopy;
                         ovbcopy_vector = i586_bcopy;
                 }
                 if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
                         bzero = i586_bzero;
                 if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
                         copyin_vector = i586_copyin;
                         copyout_vector = i586_copyout;
                 }
         }
 #endif
 
 [...]
 
 ----------
 

From: Bruce Evans <bde@zeta.org.au>
To: bde@zeta.org.au, yensid@imsa.edu
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/3391: Pentium optimizations in default bootdisk breaks some 486's
Date: Sat, 26 Apr 1997 17:40:35 +1000

 >>>	On all current boot disks, on certain 486's (mine, at least)
 >>...
 >>This can't have anything to do with i586 optimizations.  There are no i586
 >
 >Actually, I think there was a version mix-up; I filed the problem report
 >from a system running 2.1.7, I'm having this problem with 2.2 and later.
 >Sorry 'bout that
 
 Also a CPU mixup? :-)  i586 optimizations are not used on 486's.
 
 >When I posed this problem to the general problems list, I received responses
 >indicating that this was a problem with the 586 optimizations, and the
 >source seems to agree:
 >
 >freebsd-src/sys/i386/isa/npx.c
 >[...]
 
 This decides whether the i586 copying optimizations are used.  They are
 only used on i586's, and then only if they aren't disabled.  There is no
 need to recompile without I586_CPU to control them.  So if recompiling
 without i586_CPU makes a difference, then the problem must have nothing
 to do with known problems with i586 optimizations :-).
 
 Bruce

From: Don Schmidt <yensid@coke.imsa.edu>
To: Bruce Evans <bde@zeta.org.au>
Cc: yensid@imsa.edu, FreeBSD-gnats-submit@FreeBSD.org,
        yensid@postoffice.imsa.edu
Subject: Re: kern/3391: Pentium optimizations in default bootdisk breaks some 486's 
Date: Sat, 26 Apr 1997 18:12:54 -0500

 In message <199704260740.RAA30350@godzilla.zeta.org.au>, Bruce Evans writes:
 >>>>	On all current boot disks, on certain 486's (mine, at least)
 >>>...
 >>>This can't have anything to do with i586 optimizations.  There are no i586
 
 >Also a CPU mixup? :-)  i586 optimizations are not used on 486's.
 >
 >This decides whether the i586 copying optimizations are used.  They are
 >only used on i586's, and then only if they aren't disabled.  There is no
 >need to recompile without I586_CPU to control them.  So if recompiling
 >without i586_CPU makes a difference, then the problem must have nothing
 >to do with known problems with i586 optimizations :-).
 
 	Again, when I first asked for help, It was indicated to me that
 "586 optimizations caused problems on some 486's" and that I could fix the
 problem by passing the flag 0x1 to the npx driver, which appears to disable
 the bzero optimizations.  I can't do that, though, because my screen gets
 mucked up before I can get to the configuration screen.
 
 	Assuming that this isn't the problem, though, would you have any
 suggestions as to what is wrong?  I just want to be able to boot! :)
 Thanks!
 
 ===============================================================================
 Don Schmidt					  Network Systems Administrator
 yensid@imsa.edu				      Illinois Math and Science Academy
 ----------You can build a Mainframe from the things you find at home!----------

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: yensid@coke.imsa.edu
Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: kern/3391: Pentium optimizations in default bootdisk breaks some
	 486's 
Date: Sun, 27 Apr 1997 17:14:47 +0900

 > >Also a CPU mixup? :-)  i586 optimizations are not used on 486's.
 > >
 > >This decides whether the i586 copying optimizations are used.  They are
 > >only used on i586's, and then only if they aren't disabled.  There is no
 > >need to recompile without I586_CPU to control them.  So if recompiling
 > >without i586_CPU makes a difference, then the problem must have nothing
 > >to do with known problems with i586 optimizations :-).
 > 
 > 	Again, when I first asked for help, It was indicated to me that
 > "586 optimizations caused problems on some 486's" and that I could fix the
 > problem by passing the flag 0x1 to the npx driver, which appears to disable
 > the bzero optimizations.  I can't do that, though, because my screen gets
 > mucked up before I can get to the configuration screen.
 
 As Bruce pointed out, i586 optimized bcopy() has no effect on 486.
 
 Judging from the description of your problem, I would think that the
 video mode parameter table in BIOS on your video card is not ordered
 as the console driver (syscons) expects.
 
 This problem is also reported by others. Soeren, the author of syscons,
 and I have been working on this and now have a patch under testing(see
 below).
 
 If you have a spare video card (or can borrow one from someone), put
 that card in your system in place of the Diamond card. After
 installing 2.2, you can do:
 
 1) Configure the kernel to use pcvt instead of syscons.
 2) Or, apply the following patch to /sys/i386/isa/syscons.c and
    rebuild the kernel.
 
 Then you can put the Diamond card back in your system. I would prefer
 you to take the option 2) and report the result, so that we can know
 if the patch works. 
 
 Kazu
 
 --- ../syscons.c-1.209	Sat Apr 12 17:58:09 1997
 +++ syscons.c	Sun Apr 20 12:28:18 1997
 @@ -126,6 +126,7 @@
  	char		font_14[256*14];
  	char		font_16[256*16];
  	char        	palette[256*3];
 +static  char		vgaregs[64];
  static	char 		*cut_buffer;
  static  u_short 	mouse_and_mask[16] = {
  				0xc000, 0xe000, 0xf000, 0xf800,
 @@ -200,6 +201,9 @@
  static void set_keyboard(int command, int data);
  static void update_leds(int which);
  static void set_vgaregs(char *modetable);
 +static void read_vgaregs(char *buf);
 +static int comp_vgaregs(u_char *buf1, u_char *buf2);
 +static void dump_vgaregs(u_char *buf);
  static void set_font_mode(void);
  static void set_normal_mode(void);
  static void set_destructive_cursor(scr_stat *scp);
 @@ -489,6 +493,19 @@
  
      update_leds(scp->status);
  
 +    if (bootverbose) {
 +        printf("sc%d: BIOS video mode:%d\n", 
 +	    dev->id_unit, *(u_char *)pa_to_va(0x449));
 +        printf("sc%d: VGA registers upon power-up\n", dev->id_unit);
 +        dump_vgaregs(vgaregs);
 +        printf("sc%d: video mode:%d\n", dev->id_unit, scp->mode);
 +        if (video_mode_ptr != NULL) {
 +            printf("sc%d: VGA registers for mode:%d\n", 
 +		dev->id_unit, scp->mode);
 +            dump_vgaregs(video_mode_ptr + (64*scp->mode));
 +        }
 +    }
 +
      printf("sc%d: ", dev->id_unit);
      if (crtc_vga)
  	if (crtc_addr == MONO_BASE)
 @@ -2429,6 +2446,7 @@
  	u_long  segoff;
  
  	crtc_vga = TRUE;
 +	read_vgaregs(vgaregs);
  
  	/* Get the BIOS video mode pointer */
  	segoff = *(u_long *)pa_to_va(0x4a8);
 @@ -2445,6 +2463,12 @@
      init_scp(console[0]);
      cur_console = console[0];
  
 +    /* discard the video mode table if we are not familiar with it... */
 +    if (video_mode_ptr) {
 +        if (comp_vgaregs(vgaregs, video_mode_ptr + 64*console[0]->mode)) 
 +            video_mode_ptr = NULL;
 +    }
 +
      /* copy screen to temporary buffer */
      bcopyw(Crtat, sc_buffer,
  	   console[0]->xsize * console[0]->ysize * sizeof(u_short));
 @@ -3321,6 +3345,80 @@
  }
  
  static void
 +read_vgaregs(char *buf)
 +{
 +    int i, j;
 +    int s;
 +
 +    bzero(buf, 64);
 +
 +    s = splhigh();
 +
 +    outb(TSIDX, 0x00); outb(TSREG, 0x01);   	/* stop sequencer */
 +    outb(TSIDX, 0x07); outb(TSREG, 0x00);   	/* unlock registers */
 +    for (i=0, j=5; i<4; i++) {           
 +	outb(TSIDX, i+1);
 +	buf[j++] = inb(TSREG);
 +    }
 +    buf[9] = inb(MISC + 10);      		/* dot-clock */
 +    outb(TSIDX, 0x00); outb(TSREG, 0x03);   	/* start sequencer */
 +
 +    for (i=0, j=10; i<25; i++) {       		/* crtc */
 +	outb(crtc_addr, i);
 +	buf[j++] = inb(crtc_addr+1);
 +    }
 +    for (i=0, j=35; i<20; i++) {          	/* attribute ctrl */
 +        inb(crtc_addr+6);           		/* reset flip-flop */
 +	outb(ATC, i);
 +	buf[j++] = inb(ATC + 1);
 +    }
 +    for (i=0, j=55; i<9; i++) {           	/* graph data ctrl */
 +	outb(GDCIDX, i);
 +	buf[j++] = inb(GDCREG);
 +    }
 +    inb(crtc_addr+6);           		/* reset flip-flop */
 +    outb(ATC, 0x20);            		/* enable palette */
 +
 +    buf[0] = *(char *)pa_to_va(0x44a);		/* COLS */
 +    buf[1] = *(char *)pa_to_va(0x484);		/* ROWS */
 +    buf[2] = *(char *)pa_to_va(0x485);		/* POINTS */
 +    buf[3] = *(char *)pa_to_va(0x44c);
 +    buf[4] = *(char *)pa_to_va(0x44d);
 +
 +    splx(s);
 +}
 +
 +static int 
 +comp_vgaregs(u_char *buf1, u_char *buf2)
 +{
 +    int i;
 +
 +    for(i = 0; i < 24; ++i) {
 +	if (*buf1++ != *buf2++)
 +	    return 1;
 +    }
 +    buf1 += 2;	/* skip the cursor position register value */
 +    buf2 += 2;
 +    for(i = 26; i < 64; ++i) {
 +	if (*buf1++ != *buf2++)
 +	    return 1;
 +    }
 +    return 0;
 +}
 +
 +static void
 +dump_vgaregs(u_char *buf)
 +{
 +    int i;
 +
 +    for(i = 0; i < 64;) {
 +	printf("%02x ", buf[i]);
 +	if ((++i % 16) == 0)
 +	    printf("\n");
 +    }
 +}
 +
 +static void
  set_font_mode()
  {
      int s = splhigh();
 @@ -3392,6 +3490,9 @@
  	modetable = video_mode_ptr + (64*M_VGA_C80x25);
      }
  
 +    if (video_mode_ptr == NULL)
 +	modetable = vgaregs;
 +
      /* setup vga for normal operation mode again */
      inb(crtc_addr+6);           		/* reset flip-flop */
      outb(ATC, 0x10); outb(ATC, modetable[0x10+35]);
 @@ -3803,8 +3904,12 @@
  {
      static int toggle = 0;
      static u_char save_mode;
 -    int s = splhigh();
 +    int s;
 +
 +    if (video_mode_ptr == NULL)
 +	return;
  
 +    s = splhigh();
      if (toggle) {
  	scp->mode = save_mode;
  	scp->status &= ~UNKNOWN_MODE;
 
 
State-Changed-From-To: open->closed 
State-Changed-By: yokota 
State-Changed-When: Mon May 12 03:44:28 PDT 1997 
State-Changed-Why:  
This is considered to be the same problem as conf/2775 and kern/2896. 
Both are fixed in 3.0-970502-SNAP and the same fix is now in RELENG_2_2  
(syscons.c 1.182.2.18) too. 
>Unformatted:
