Subject: Re: Quadra 610 (and others) internal video
To: None <port-mac68k@NetBSD.ORG>
From: Michael R. Zucca <mrz5149@cs.rit.edu>
List: port-mac68k
Date: 01/15/1997 14:08:56
>.. This patch works, but I do not know whether the 512*1024 is good or
>.. bad -- how do I determine this ?
>
>One further bit of information: The Q610 has either 1/2 or 1/1 MB of
>VRAM. Maybe the value above should really be 1024 * 1024 ?

Umm, well, I would suggest not even bothering with a table. You should be able
to size the video ram and other stuff like the ROMs pretty easily using one
routine.It's too bad I don't have more time to work on the video code because
I wanted to add a new sizing method but my time constraints for the next
month and a half are insane. :(

Somebody with more free time should hack the following stuff in somewhere
and use it early on in the boot process when all the memory regions get sized.
Here's the algorithm:

Since regions like ROM and VRAM are bounded by "red zones" of unmapped
memory addresses under the Apple memory mapping you can use a loop and
a bus error handler to figure out how large a memory space is.

(I actually have a code snippet somewhere but not with me right now)

What you do is tell the NetBSD bus error handler that you're probing and then
setjmp to your own handler routine. Here's some pseudocode:

nobuserr = 1 ;  /* Tell the bus error handler we're probing */

setjmp handlebus ; /* When a bus error occurs the bus err handler longjmp's
                      to this label */

for(i=start_address; i<start_address+1Meg*5; i+=128k)
{
        /* Check every 128k for the next 5 Megs */
        dummy = *i ; /* Force a memory read */
}

/* If we got here something's goofy. Nobody's got 5 megs of VRAM! */
nobuserr = 0 ; /* Let the system handle bus errors normally */
panic("Can't find end of video memory!") ;

handlebus:
/* If we're here we've gone to size+128k */
nobuserr = 0 ;
return i-128k ;

And that's it. There are some pitfalls and refinements that are needed. One,
in the case of ROM, there are possible "red zones" inside the ROM memory space
on some Quadras so the simple for loop would have to be replaced by
routines that check certain offsets from the start of ROM. We can also
optimize the loop for common cases like checking VRAM at 128,512,1024,2048
and 4096. I also think it might be wise to add another for loop that backs off
from the size found by the first loop by 2*128k and then advances byte-wise
to find the exact memory location down to the byte. That way you know *exactly*
where the memory block ends. A good function should take a start address and
return a length.

This is much better than a table approach since it works on any machine.
Besides, the setjmp functionality was built in for just this purpose.

I really hope somebody adds this!

Thanks.

_______________________________________________________________________
 Michael Zucca - mrz5149@rit.cs.rit.edu - http://www.rit.edu/~mrz5149/
 "I will choose a path that's clear. I will choose Freewill. "
  --Rush, Freewill
_______________________________________________________________________