[LinuxBIOS] DIMM Page Size

Joseph Smith joe at smittys.pointclark.net
Fri Jul 13 13:21:47 CEST 2007


Quoting Peter Stuge <peter at stuge.se>:

> On Fri, Jul 13, 2007 at 01:44:52AM -0400, Joseph Smith wrote:
>> 			/* convert to Kilobytes */
>> 			dra = ((page_size / 8) >> 10);
>
> Please don't use bit shifting for multiplication and division.
>
> page_size / 8 / 1024
>
> is nicer to read, and the compiler will probably optimize both
> statements to a single >> 13 anyway.

> 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?

>
> Note also that you're now using the dra variable to hold something
> very different from the DRA value, while the rest of the function
> pretty much has one variable for each register. Variables (ie
> registers) are scarce during RAM init so I think re-use is good.
>
Yup, DRA is the registers address, and dra is it's value.
>
> But I think this is simpler:
>
> dra = log2(dra);
> if (dra > 3) {
>   print_debug("incompatible\n");
>   die("bye");
> }
> dra |= 0xf0;
>
>
What does the log2 function do? And in what file does it live?

Thanks - Joe




More information about the coreboot mailing list