Getting total system memory.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
smbogan
Member
Member
Posts: 29
Joined: Tue Nov 21, 2006 3:17 pm

Getting total system memory.

Post by smbogan »

I'm relatively sure this has been talked about before, but a search didn't get me anywhere.

I'm booting with GRUB straight into protected mode. What's an effective way of getting the total system memory?

Thanks for any help.
urxae
Member
Member
Posts: 149
Joined: Sun Jul 30, 2006 8:16 am
Location: The Netherlands

Post by urxae »

Did you read the Multiboot specification? Specifically, the section on the boot information format?
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Post by Walling »

Since you use GRUB I agree with urxae. Use the multiboot information. Otherwise read How do I determine the amount of RAM? on OsFaq2.
smbogan
Member
Member
Posts: 29
Joined: Tue Nov 21, 2006 3:17 pm

Post by smbogan »

Thanks, I got the info from the multiboot specification to work nicely. I'm just curious if anyone knows the following, in regaurds to the memory map structure:
where `size' is the size of the associated structure in bytes, which can be greater than the minimum of 20 bytes. `base_addr_low' is the lower 32 bits of the starting address, and `base_addr_high' is the upper 32 bits, for a total of a 64-bit starting address. `length_low' is the lower 32 bits of the size of the memory region in bytes, and `length_high' is the upper 32 bits, for a total of a 64-bit length. `type' is the variety of address range represented, where a value of 1 indicates available ram, and all other values currently indicated a reserved area.
The multiboot specification says that the type number of 1 represents available. Does anyone know what 2-4 mean. I mean beyond the definition of reserved.

Thanks.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

I think it's the same as in int15 ah=0xE820 (http://www.ctyme.com/intr/rb-1741.htm) - at least, this method and GRUB both seem to give me the same memory regions on both Bochs and VPC...

HTH
Adam
Post Reply