The amount of RAM in a machine almost always has just one or two "1"
bits.
8, 16, 20, 24, 32, 36, 40, 48, 64, 80 Mb were the numbers that you'd
see in the early Pentium times, right?
So rounding up would mean: Add one until the number of 1-bits in the
address is less than 3. People with 3 or more differently sized DIMMS
in their machine will experience a slightly ineffcient round-up.
Speed this up with: Find-lowest-1-bit, add that.
Example you quoted:
nr of 1 bits.
BIOS-proclaimed end-of-ram: 0x13fff0000 15
lowest 1-bit: 0x000010000 1
add: 0x140000000 2
long round_highmem (long val)
{
while (hweight32 (val) > 2)
val += 1 << ffs (val);
return val;
}
Roger.
-- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* * There are old pilots, and there are bold pilots. * There are also old, bald pilots. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/