Hi,
mordak wrote:i use virtual pc and grub to load kernel and get memory map and i see lot of code about Grub Mem Map but its return last mem map values negaive?
All of the values in the memory map (base, length, type, etc) are
unsigned integers, which means that if you get a negative number displayed then you're printing them as
signed integers and not
unsigned integers. This is your first mistake; for example, if you print the unsigned 32-bit integer 0xFFFC0000 as a signed 32-bit integer, you'd get the (negative) value -0x00040000.
Half of the values in the memory map (base and length) are
64-bit unsigned integers. For example, the value 0x00000000FFFC0000 is an unsigned 64-bit value. If you (incorrectly) print it as a signed 64-bit value then it'd still be displayed correctly (and won't be negative). Basically, this is the second mistake (printing a 64-bit integer as a 32-bit integer).
Also note that (because hex is normally only used for things like addresses, bit fields, masks, etc), when a hex number is displayed the leading zeros should probably be kept to indicate size. For example, "0x0002" is a 16-bit integer, which is very different to "0x02" (a byte) or "0x2" (half a byte).
This means that the last entry of the memory map *should* look like this:
Code: Select all
size = 0x14, base_addr = 0x00000000FFFC0000, length = 0x0000000000040000, type = 0x02
Of course this is perfectly normal - it describes a 256 KiB ROM exactly where it should be.
Cheers,
Brendan