Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: problem reading VGA text fonts
@ 1996-11-20 14:37 Bender, Bernhard
  0 siblings, 0 replies; 11+ messages in thread
From: Bender, Bernhard @ 1996-11-20 14:37 UTC (permalink / raw)


Hi,

>>>
now the interesting question is:  how can we read the BIOS (esp. on AXP)
without currupting video memory ?
<<<

Basically, you can't :-(

One possible solution may be to save all of the VGA memory before reading 
the ROM, and restore it afterwards.

The reading of the BIOS ROM itself causes corruption of memory contents, 
no matter how you do it. You can read fast or slow, byte of Dwords, no 
change.

On Wintel machines, there is not problem, as PCI spec requires the VGA 
BIOS to be copied to RAM before execution. The BIOS emulation on the AXP 
machine will do the same, but does not keep the copy after it is done (at 
least I guess so).

>>>
thanks a lot for this big hint (why didn't I ask earlier? :-(
<<<

If you had asked me two weeks ago, I wouldn't have known, we only found 
our very recently, after looking for the reason of the problem for about 
4 months, together with engineer at a large computer manufacturer... So 
that wasn't really easy, an I only found out the ROM access by 
coincidence.

As for what S3 chips may be affected: The ViRGE for sure, maybe the 
TrioV+ also. There is no mention in S3's stepping info about this.

Bernhard Bender

---
Group Manager Core Technology   ELSA Computer Graphics

ELSA GmbH             		Email: br@elsa.de
Sonnenweg 11                    Fax  : +49 (2405) 450 100
D-52 070 Aachen, Germany        WWW  : http://www.elsa.de

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: problem reading VGA text fonts
@ 1996-11-20 21:57 Bender, Bernhard
  0 siblings, 0 replies; 11+ messages in thread
From: Bender, Bernhard @ 1996-11-20 21:57 UTC (permalink / raw)


Hi Harald,

your're a bright guy, really.

I was sure there is no workaround for this. But you have found one. 
Setting CR66 bit 1 while reading the BIOS ROM does prevent DRAM 
corruption.

I wonder what happens if you keep this bit set for too long. Possibly 
DRAM will loose some of its data becase DRAM refresh is also stopped...

But still I think, this think should go into the S3 server to protect 
reading the ROM on the Trio and ViRGE chips.

Thanks!
Bernhard Bender

---
Group Manager Core Technology   ELSA Computer Graphics

ELSA GmbH             		Email: br@elsa.de
Sonnenweg 11                    Fax  : +49 (2405) 450 100
D-52 070 Aachen, Germany        WWW  : http://www.elsa.de

***  Original Message Follows  ***
> >>>
> now the interesting question is:  how can we read the BIOS (esp. on 
AXP)
> without currupting video memory ?
> <<<
> 
> Basically, you can't :-(

knowing the real reason for the font/memory corruption it's easy to
write a small test program and play with.  for a Trio64V+ card 
I see horrible things going on on the screen while this program
reads the BIOS.  
but with S3 864 and 968 I don't see any problems with fonts here.

below is the test program.  if you see any font/screen corruption
when running it (maybe several times; can be cleaned up with "setfont" 
again)
you should try to set RESET_S3 to 1 and see if this fixes 
corruption for your card/machine...

also you can test SPARSE memory bios access if you set TEST_JENSEN_CODE 
to 1.
didn't make any difference for me (but with SPARSE access, copying
was >3 times faster then using DENSE access..)

now I could play with it a bit trying to find a better workaround
than saving the whole frame buffer before accessing the BIOS.

at least for the Trio64V+ card  there is no problem when I reset 
the S3 graphics engine using CR66 bit 1 while reading the BIOS.
haven't tested this for ViRGE yet but at least the GE can be reset
with the same bit...

> As for what S3 chips may be affected: The ViRGE for sure, maybe the 
> TrioV+ also. 

Trio64V+ for sure too (at least for my AXP box)

> There is no mention in S3's stepping info about this.

:-(

Harald
--------------------------------------------------------------------------
-----
#define TEST_JENSEN_CODE 	0
#define RESET_S3		0
#define WRITE_BIOS_TO_STDOUT	0
#define SIZE (2*32*1024)

#ifdef __alpha__
#include <sys/io.h>
#else
#include <asm/io.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>

#if TEST_JENSEN_CODE /* define to test the Sparse addressing on a 
non-Jensen */
#define SPARSE (5)
#define isJensen (1)
#else
#define isJensen (!_bus_base())
#define SPARSE (7)
#endif

extern unsigned long _bus_base(void);
extern unsigned long _bus_base_sparse(void);
#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base())
#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x)

#ifdef __alpha__

/* The outb() isn't needed on my machine, but who nows ... -- ost */
void
SlowBcopy(src, dst, len)
unsigned char *dst, *src;
int len;
{
    while(len--)
    {
	*dst++ = *src++;
	outb(0x80, 0x00);
    }
}

void
SlowBCopyFromBus(src, dst, count)
     unsigned char *src, *dst;
     int count;
{
    if (isJensen) /* Jensen */
    {
	unsigned long addr;
	long result;

	addr = (unsigned long) src;
	while( count ){
	    result = *(volatile int *) addr;
	    result >>= ((addr>>SPARSE) & 3) * 8;
	    *dst++ = (unsigned char) (0xffUL & result);
	    addr += 1<<SPARSE;
	    count--;
	    outb(0x80, 0x00);
	}
    }
    else
	SlowBcopy(src,dst,count);
}
#endif
  
int xf86ReadBIOS(Base, Offset, Buf, Len)
     unsigned long Base;
     unsigned long Offset;
     unsigned char *Buf;
     int Len;
{
#ifdef __alpha__
  /*
   * The Alpha version uses "mmap" instead of "lseek/read",
   *  because these (currently) don't work for BUS memory.
   * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
   *  which is the KSEG address of the start of the DENSE memory
   *  area.
   */

  /*
   * NOTE: there prolly ought to be more validity checks and all
   *  re: boundaries and sizes and such...
   */

/*
 * The Jensen lacks dense memory, thus we have to address the bus via
 * the sparse addressing scheme.
 *
 * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
 */

	caddr_t base;
 	int fd;

	if ((fd = open("/dev/mem", O_RDONLY)) < 0)
	{
	  perror("xf86ReadBios: Failed to open /dev/mem");
	  return(-1);
	}

	base = mmap((caddr_t)0, JENSEN_SHIFT(SIZE), PROT_READ,
		    MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE));

	if (base == (caddr_t)-1UL)
	{
	  perror("xf86ReadBios: Failed to mmap /dev/mem");
	  return(-1);
	}

	SlowBCopyFromBus(base+JENSEN_SHIFT(Offset), Buf, Len);

	munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(SIZE));
	close(fd);
	return(Len);

#else /* __alpha__ */

 	int fd;

	if ((fd = open("/dev/mem", O_RDONLY)) < 0)
	{
	  perror("xf86ReadBios: Failed to open /dev/mem");
	  return(-1);
	}

	if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
	{
	  perror("xf86ReadBios: /dev/mem seek failed");
	  close(fd);
	  return(-1);
	}
	if (read(fd, Buf, Len) != Len)
	{
	  perror("xf86ReadBios: /dev/mem read failed");
	  close(fd);
	  return(-1);
	}
	close(fd);
	return(Len);
#endif /* __alpha__ */
}

void main()
{
  char bios[SIZE];
#if RESET_S3
  int tmp;
#endif

  iopl(3);

#if RESET_S3
  outb(0x38, 0x3d4);
  outb(0x48, 0x3d5);
  outb(0x39, 0x3d4);
  outb(0xa5, 0x3d5);

  /* reset S3 graphics engine */
  outb(0x66, 0x3d4);
  tmp = inb(0x3d5);
  outb(tmp |  0x02, 0x3d5);
  usleep(10000);  /* wait a little bit... */
#endif

  xf86ReadBIOS(0xc0000, 0, bios, SIZE);

#if RESET_S3
  outb(0x66, 0x3d4);
  outb(tmp & ~0x02, 0x3d5);
  usleep(10000);  /* wait a little bit... */
#endif

#if WRITE_BIOS_TO_STDOUT
  write(1,bios,SIZE);
#endif
}

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ 
OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^
***  End of Original Message  ***

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: problem reading VGA text fonts
@ 1996-11-20 19:12 Bender, Bernhard
  0 siblings, 0 replies; 11+ messages in thread
From: Bender, Bernhard @ 1996-11-20 19:12 UTC (permalink / raw)


Hi,

Let me say it again: Every single access has the potential to corrupt 
memory. There is not workarround. If you do few accesses, you'll seldomly 
see the problem.

Bernhard Bender

---
Group Manager Core Technology   ELSA Computer Graphics

ELSA GmbH             		Email: br@elsa.de
Sonnenweg 11                    Fax  : +49 (2405) 450 100
D-52 070 Aachen, Germany        WWW  : http://www.elsa.de

***  Original Message Follows  ***
On Wed, 20 Nov 1996, Bender, Bernhard wrote:

> >>>
> now the interesting question is:  how can we read the BIOS (esp. on 
AXP)
> without currupting video memory ?
> <<<
> 
> Basically, you can't :-(
> 
> The reading of the BIOS ROM itself causes corruption of memory 
contents, 
> no matter how you do it. You can read fast or slow, byte of Dwords, no 
> change.

maybe if using special alignment? eg. only reading the first 64 bits of a
page. Or the last 64 bits.

-- mingo

***  End of Original Message  ***

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <AD1C9332019C1400@smtpgate.elsa.de>]
* Re: problem reading VGA text fonts
@ 1996-11-20  9:04 Martin Ostermann
  0 siblings, 0 replies; 11+ messages in thread
From: Martin Ostermann @ 1996-11-20  9:04 UTC (permalink / raw)


koenig@tat.physik.uni-tuebingen.de (Harald Koenig) writes:
> > Maybe the BIOS is not shadowed on the AXP machine?
> no idea

Usually, like any i/o, neither shadowed, nor cached. Makes sense, 
since it's usually not being executed on the AXPs.

Martin

-- 
Martin Ostermann                | mailto:ost@comnets.rwth-aachen.de
Communication Networks          | http://www.comnets.rwth-aachen.de/~ost
Aachen University of Technology | phoneto:++49/241/807917
Germany                         | faxto:++49/241/8890378

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: problem reading VGA text fonts
@ 1996-11-19 20:50 Bender, Bernhard
  0 siblings, 0 replies; 11+ messages in thread
From: Bender, Bernhard @ 1996-11-19 20:50 UTC (permalink / raw)


Hi Harald,

>>>
I see 3 different types of font corruptions:

- some few ramdom pixels set (sometimes cleared) in the character glyph
- completely trashed glygh (random pattern)
- block of 16 characters/glyphs is "shifted", e.g. very often ASCII  
  0x30-0x3f (digits etc. up to '?')  displays glyphs for ASCII 0x20-0x2f
  so pressing '1' I see a '!'
  since one character glyph is 32 bytes when saved/restored, the size
  of such a "shifted" block is always 512 bytes.  any idea about this 
size? 
<<<

Well, we have seen something very similar recently. I happend only rarely 
during the boot procedure of the system BIOS on a very spacial (but 
important :-) computer.

After very long search the problem was pinned down on accesses to the 
BIOS ROM (the physical, not the shadowed image). These accesses cause 
memory corruptions with ViRGE (and some other S3 chips).

Are you accessing the (physical) VGA BIOS ROM somewhere to detect the 
type of board? Maybe the BIOS is not shadowed on the AXP machine?

Bernhard Bender

---
Group Manager Core Technology   ELSA Computer Graphics

ELSA GmbH             		Email: br@elsa.de
Sonnenweg 11                    Fax  : +49 (2405) 450 100
D-52 070 Aachen, Germany        WWW  : http://www.elsa.de

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <m0vPuen-0001bSC@ceres.tat.physik.uni-tuebingen.de>]
[parent not found: <8AE99132019C1400@smtpgate.elsa.de>]
* Re: problem reading VGA text fonts
@ 1996-11-19 12:24 Martin Ostermann
  0 siblings, 0 replies; 11+ messages in thread
From: Martin Ostermann @ 1996-11-19 12:24 UTC (permalink / raw)


koenig@tat.physik.uni-tuebingen.de (Harald Koenig) writes:

> 
> what's different between AXP and x86 ?

Hm, just came back to my mind ... When I did my first Jensen patch, I
used BusToMem() to replace slowbcopy. That didn't work. The difference
basically was, that BusToMem() reads a word at a time, not bytes.

If you use DENSE memory, the AXP reads a quadword at a time. The
SlowBcopy routine does this. Maybe this isn't OK on some cards?
OTOH, the outb() in there should make sure that that's done for each
byte to read.

Anyway, there's probably a reason that this routine was called
slowb(yte)copy in the first place.
 
> what should be tested/checked next ?

Try to access the font space via SPARSE memory, a byte at a time. You
can use the Jensen Patch with TEST_JENSEN defined, but make sure you 
fix the tests in SlowBcopy.c, which weren't made depended on the
define. 

Martin

-- 
Martin Ostermann                | mailto:ost@comnets.rwth-aachen.de
Communication Networks          | http://www.comnets.rwth-aachen.de/~ost
Aachen University of Technology | phoneto:++49/241/807917
Germany                         | faxto:++49/241/8890378

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread
* problem reading VGA text fonts
@ 1996-11-19  9:01 Harald Koenig
  0 siblings, 0 replies; 11+ messages in thread
From: Harald Koenig @ 1996-11-19  9:01 UTC (permalink / raw)


Hi,

I spent a lot of time trying to find out why XF86_S3 doesn't restore
the text font correctly for DEC ALpha/AXP when switching back to text mode 
but I still don't know why  and now I need your help and ideas.
tests (see below) show that the font gets corrupted when trying to read/save
it from the VGA card when starting X11.

NOTE that his problem only shows up for Alpha/AXP, I never saw any
text font corruption for any of my cards (all S3) with my Intel PC.

first I thougt it's a problem only with the ViRGE card but it happens
too with S3 864, Trio64V+ and 968.  also I got a report that it's not
only my XL266 box but at least also a problem with a PC64/300 box with S3 cards.

does anyone else have problems with text font corruption ?
since the save/restore code is the same for all VGA cards I'd like
to know if this only happens for S3 or for other cards too
(it's always Xserver/hw/xfree86/vga256/vga/vgaHW.c).

this doesn't happen all the time but starting X several times 
probably will show it; e.g. use

	n=1; while [ $n -le 20 ] ; do xinit & sleep 5 ; killall xterm ; n=$[ $n+1 ] ; done

if you see any corruption, please mention card and chip, which alpha
architecture, cpu etc.  and which type of corruption.

I see 3 different types of font corruptions:

- some few ramdom pixels set (sometimes cleared) in the character glyph
- completely trashed glygh (random pattern)
- block of 16 characters/glyphs is "shifted", e.g. very often ASCII  
  0x30-0x3f (digits etc. up to '?')  displays glyphs for ASCII 0x20-0x2f
  so pressing '1' I see a '!'
  since one character glyph is 32 bytes when saved/restored, the size
  of such a "shifted" block is always 512 bytes.  any idea about this size? 

looking at the code of vgaHWsave() in vgaHW.c I tried lots of things:

- writing the font/text areas to a file directly after copying it from
  the card shows that here it's already bad (if font gets corrupted when leaving X)

- tried to use outb() instead of outw()

- tried lots of different copy routines (tried memcpy() too) and delays
  in/after slowbcopy (slowbcopy does a mem_barrier() after every single
  byte copied when calling outb(0x80, 0x00))

- changed the order of the SAVE_FONT1, SAVE_FONT2 and SAVE_TEXT blocks
  (text is never corrupted; maybe this is restored by the Linux kernel
  vc switching ?)
  
- added some code to do a syncronous reset on SR like in linux kernel code
  in linux/drivers/char/vga.c

- tried to copy area multiple times and compare destinantions; 
  they are always the same

any idea what might explain these types of corruptions?

what's the "magic" about 512 byte font blocks? why are always 16 characters
overwritten by some "shifted" glyphs (always 16glyph-aligned) ?

what's different between AXP and x86 ?

what should be tested/checked next ?

thanks for any idea,

Harald

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~1996-11-20 21:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-11-20 14:37 problem reading VGA text fonts Bender, Bernhard
  -- strict thread matches above, loose matches on Subject: below --
1996-11-20 21:57 Bender, Bernhard
1996-11-20 19:12 Bender, Bernhard
     [not found] <AD1C9332019C1400@smtpgate.elsa.de>
1996-11-20 12:17 ` Ingo Molnar
1996-11-20 14:40 ` Harald Koenig
1996-11-20  9:04 Martin Ostermann
1996-11-19 20:50 Bender, Bernhard
     [not found] <m0vPuen-0001bSC@ceres.tat.physik.uni-tuebingen.de>
1996-11-19 18:43 ` Ingo Molnar
     [not found] <8AE99132019C1400@smtpgate.elsa.de>
1996-11-19 18:12 ` Harald Koenig
1996-11-19 12:24 Martin Ostermann
1996-11-19  9:01 Harald Koenig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox