How does a BIOS determine the amount of available RAM?

3

If the BIOS is a 16-bit program running in real mode, and in this mode it possible to address only 1MB, how does the BIOS determine the amount of available RAM, like 1 GB for example?

PositronicBrain

Posted 2015-09-17T17:24:50.450

Reputation: 41

1Is this a homework question? – Xavierjazz – 2015-09-17T17:33:44.247

1If so, I want to take that class. – dsolimano – 2015-09-17T17:45:38.617

I'm studying assembly language, just as a hobby, and I want to learn the basics, and how a PC works. I'm not a college student, just curious. Thanks for your time anyway =) – PositronicBrain – 2015-09-17T18:39:06.997

Answers

7

The BIOS is a 16-bit program running in real mode, and in this mode it is possible to address only 1MB.

This is incorrect.

16-bit real mode does not limit the processor to 1MB of memory.

While it's true that an x86 processor starts out in real mode, and defaults to the 16-bit 8086 instruction set, there are extensions in the 80286 instrution set. If you prefix an 8086 instruction with the byte 0x67, this will allow that instruction access to a 32-bit register, which has access to 232 bytes, or 4GiB of memory.

If you are using a 64-bit processor, the processor can use PAE (Physical Address Extension), which gives the processor access to 252 bytes of memory, more than can be physically installed on any modern motherboard.

Source How BIOS can detect full extended memory size


How does the BIOS determine the amount of available RAM, like 1 GB for example?

It uses methods that are documented in the datasheets for the memory controller (northbridge).

Most BIOSes can't use any RAM until they detect the type of RAM installed, then detect the size of each memory module, then configure the chipset to use the detected RAM.

All of this depends on chipset specific methods, and is usually documented in the datasheets for the memory controller (northbridge).

The RAM is unusable for running programs during this process. The BIOS initially is running from ROM, so it can play the necessary games with the RAM chips. But it is completely impossible to do this from inside any other program.

Source Detecting Memory (x86)

DavidPostill

Posted 2015-09-17T17:24:50.450

Reputation: 118 938

Thanks a lot man. Thank you for providing your time to answer my question. Actually, I still have a lot to learn. PS: my question was answered very very fast LOL. – PositronicBrain – 2015-09-17T18:31:25.063

On detecting memory: the DIMMS have a small EPROM that says what they are and what timings should be used. https://en.wikipedia.org/wiki/Serial_presence_detect

– pjc50 – 2015-10-20T15:25:07.913

3The first quotation is neither correct, nor relevant to the question. First off, there is a typo that says "80286" when it should be "80386". Second, the ability to use 32-bit registers has nothing to do with the ability to address memory. When running in real mode, you're still limited to 20-bit address lines, regardless of the register size. Third, PAE is available on lots of processors that do not support 64-bit extensions. Fourth, the quotation's implication is also wrong. Real mode is limited to addressing only 1 MB; it just isn't necessary to address the memory to count it. – Cody Gray – 2017-07-10T04:08:26.730