[LinuxBIOS] DIMM Page Size

Peter Stuge peter at stuge.se
Fri Jul 13 13:36:22 CEST 2007


On Fri, Jul 13, 2007 at 07:21:47AM -0400, Joseph Smith wrote:
> Quoting Peter Stuge <peter at stuge.se>:
> > Please don't use bit shifting for multiplication and division.
> 
> > Quoting Stefan Reinauer <stepan at coresystems.de>:
> > I think this is a bad dogma. Using shifts for mul/div is pretty
> > obvious to understand and almost courteous.
> 
> So which way is correct in linuxbios standards?

I guess either. :)


> Yup, DRA is the registers address, and dra is it's value.

Point was that dra held bank kb size.


> > dra = log2(dra);
> > if (dra > 3) {
> >   print_debug("incompatible\n");
> >   die("bye");
> > }
> > dra |= 0xf0;
> 
> What does the log2 function do?

base-2 logarithmic function

It returns the position of the leftmost 1 bit in the LE parameter.

log2(1) = 0
log2(2) = 1
log2(4) = 2
log2(8) = 3
etc

It is actually not sufficient though, since it's integer only in
romcc. Check that the kb page size is valid before calling log2(),
but it can still be used to conveniently calculate the needed value.


> And in what file does it live?

src/arch/i386/include/arch/romcc_io.h

There's also one version in util/romcc/tests/simple_test5.c that
uses __builtin_bsr() which compiles directly to the bsr opcode.


//Peter




More information about the coreboot mailing list