How can I get the amount of available RAM?

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
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

How can I get the amount of available RAM?

Post by Roman »

I have an idea, but it can slow down the bootstrap process.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: How can I get the amount of available RAM?

Post by Rusky »

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

On BIOS systems you'll want to use int e820, which gives you a map of available memory. UEFI will give you a similar map as an argument to the bootloader.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: How can I get the amount of available RAM?

Post by sortie »

Please read Forum Rules. In particular, you are not following Rule 1, where you show you have searched the forums, the wiki and google. This is pretty basic osdev material and should be easy to find. Note that you usually don't really care how much memory is available, but rather want to know exactly which memory areas are usable (as they may not be a single chunk in physical memory). You get the memory map from the component that loaded you: If you use the BIOS, you get the memory map from the BIOS. If you use UEFI, you get the memory map from UEFI. If you use GRUB, you get the memory map from GRUB.
Post Reply