Subject: Re: Problem in mac68k -current
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Paul Goyette <paul@whooppee.com>
List: current-users
Date: 05/25/1997 14:42:37
Actually, I _think_ I found the problem...

>From mac68k/dev/grf_iv.c (internal video) at line 182:

	gm->fbbase = (caddr_t) mac68k_trunc_page(mac68k_vidlog);
	gm->fboff = mac68k_vidlog & PGOFSET;

>From mac68k/dev/grf_mv.c (nubus video) at line 196:

	gm->fbbase = (caddr_t)(sc->sc_handle + image.offset); /* XXX evil! */
	gm->fboff = image.offset;

The internal video version rounds fbbase down to a page boundary, so it is
OK to add the page offset back in.  But the nubus video version actually
includes the offset in both fields, so it's no wonder that itematch() gets
the wrong value.

Seems to me that the grf_mv.c version should look more like:

	gm->fbbase = (caddr_t) mac68ktrunk_page(sc->sc_handle + image.offset);
	gm->fboff = (sc->sc_handle + image.offset)& PGOFSET;

What do you think?

On Sun, 25 May 1997, Paul Goyette wrote:

> OK, another printf() produces the following information:
> 
> 	gm->fbbase = 0x8347400, gm->fboff = 0x400
> 
> So, adding these two numbers together gives us 0x8347800, which as Jason
> points out will always make pmap_extract() return something with low order
> bits set to 0x800.
> 
> Given that my video card's frame buffer physical address is 0xfd000400, I
> rather suspect that the gm->fboff is correct;  of course, this means that
> the gm->fbbase is incorrect.
> 
> So, since this worked before (as recently as April 28th), does any one
> know what's changed?  :)
> 
> On Sun, 25 May 1997, Jason Thorpe wrote:
> 
> > On Sun, 25 May 1997 13:03:51 -0700 
> >  greywolf@starwolf.starwolf.com (Missing - presumed fed.) wrote:
> > 
> >  >  * For some strange reason, the pmap_extract() call returns a value of
> >  >  * 0xfd000800 while mac68k_vidphys contains 0xfd000400.  The latter value
> >  >  * agrees with what the booter passes in.
> >  >  * 
> >  >  * So, does anyone know why the pmap_extract() return value is 0x400 higher
> >  >  * than it (apparently) should be?  :)  Is it maybe some sort of "rounding
> >  >  * up to the next page boundary" error?
> >  > 
> >  > Well, what's pagesize() on a mac68k?  If it's 1024, then rounding is
> >  > not the problem.
> > 
> > Page size on a Mac is 4k.
> > 
> > Paul - What virtual address are you passing pmap_extract()?  If it ends
> > in "800", then you're going to get that back from pmap_extract().
> > It's returning:
> > 
> > 	page_pa | (va & PGOFSET)
> > 
> > Jason R. Thorpe                                       thorpej@nas.nasa.gov
> > NASA Ames Research Center                               Home: 408.866.1912
> > NAS: M/S 258-6                                          Work: 415.604.0935
> > Moffett Field, CA 94035                                Pager: 415.428.6939
> > 
> 
> -----------------------------------------------------------------------------
> | Paul Goyette       | PGP Public Key fingerprint:  | E-mail addresses:     |
> | Network Consultant |     0E 40 D2 FC 2A 13 74 A0  |  paul@whooppee.com    |
> | and kernel hacker  |     E4 69 D5 BE 65 E4 56 C6  |  paul_goyette@ins.com |
> -----------------------------------------------------------------------------
> 
> 

-----------------------------------------------------------------------------
| Paul Goyette       | PGP Public Key fingerprint:  | E-mail addresses:     |
| Network Consultant |     0E 40 D2 FC 2A 13 74 A0  |  paul@whooppee.com    |
| and kernel hacker  |     E4 69 D5 BE 65 E4 56 C6  |  paul_goyette@ins.com |
-----------------------------------------------------------------------------