From owner-freebsd-bugs Sun Apr 27 01:20:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id BAA03788 for bugs-outgoing; Sun, 27 Apr 1997 01:20:04 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id BAA03775; Sun, 27 Apr 1997 01:20:01 -0700 (PDT) Date: Sun, 27 Apr 1997 01:20:01 -0700 (PDT) Message-Id: <199704270820.BAA03775@hub.freebsd.org> To: freebsd-bugs Cc: From: Kazutaka YOKOTA Subject: Re: kern/3391: Pentium optimizations in default bootdisk breaks some 486's Reply-To: Kazutaka YOKOTA Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR kern/3391; it has been noted by GNATS. From: Kazutaka YOKOTA 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;