0

Grub is a multiboot compliant boot loader. When it boots an operating system it creates a structure defining the available memory and leaves a pointer to that structure in memory.

I got that information here:

http://wiki.osdev.org/Detecting_Memory_(x86)#Memory_Map_Via_GRUB

This is the structure that I think I'm interested in:

 typedef struct memory_map
 {
   unsigned long size;
   unsigned long base_addr_low;
   unsigned long base_addr_high;
   unsigned long length_low;
   unsigned long length_high;
   unsigned long type;
 } memory_map_t;

So I've got a collection of memory map structures. As the above page mentions, you can see the memory map by typing "displaymem" at the grub prompt. This is my output

But I don't fully understand the structure....

Why are the lengths set to 0 (0x0)? Do I have to combine low memory and high memory?

It says the values are in 64 bit so did it push together "low mem and high mem" together like this:

__int64 full_address = (low_mem_addr + high_mem_addr);

or am I getting 1 list containing both low and high addresses exclusively in them?

and since I'm using a 32bit machine do I basically refer to each unique address with both values?

I was expecting one single list of addresses, like displaymem shows but with actual length fields populated but I'm not seeing that. Is there something I don't understand?

Philluminati
  • 2,649
  • 2
  • 25
  • 32
  • 1
    quotation: "base_addr_low is the lower 32 bits of the starting address, and base_addr_high is the upper 32 bits", you get resulting address like that: res = baselow + basehigh<<32, but res needs to be 64 bit pointer – fazo Nov 21 '10 at 19:38
  • So why are the length's zero? Do I need to sort the list by combined starting address then to the next reserved address? I would have thought length_low and high combined would be equal to the next entry in the linked list. – Philluminati Nov 21 '10 at 19:43
  • According to the wiki link I provided, they are a combination, and I can just use unsigned long long x. – Philluminati Nov 22 '10 at 18:21

1 Answers1

0

Ok, basically it's just two variables...that are 64 bit numbers, so what is above and what is below are IDENTICAL!

typedef struct memory_map
 {
   unsigned long size;
   //unsigned long base_addr_low;
   //unsigned long base_addr_high;
   unsigned long long base_addr;
   // unsigned long length_low;
   // unsigned long length_high;
   unsigned long long length; //holds both halves.
   unsigned long type;
 } memory_map_t;

You can get the two halves out like this:

unsigned long base_addr_low = base_addr
unsigned long base_addr_high = base_addr >> 32

The question was just that simple. :-s

Philluminati
  • 2,649
  • 2
  • 25
  • 32