Page 1 of 1

Why int 15h return 4GiB RAM?

Posted: Wed Apr 17, 2013 6:25 am
by zgxltxz
I'm come from China,My English is very poor,Please understand that. :mrgreen:
I only set 64MiB RAM,Why "Address Range Descriptor Structure" return 4GiB RAM? :?:

Re: Why int 15h return 4GiB RAM?

Posted: Wed Apr 17, 2013 7:08 am
by Mikemk
There's space (lots of space) in between each section. You have 64 MB spread out over 4 GB. If you're using an emulator, it doesn't make much sense to do so, but it might be showing the actual ram locations that it has.

Re: Why int 15h return 4GiB RAM?

Posted: Wed Apr 17, 2013 7:16 am
by HugeCode
How do you get the size of RAM? From max value found?

Re: Why int 15h return 4GiB RAM?

Posted: Wed Apr 17, 2013 7:30 am
by Combuster
zgxltxz wrote:Why "Address Range Descriptor Structure" return 4GiB RAM? :?:
It doesn't. Anything over 64M is not marked as "usable ram". Check the last column of your table.

Re: Why int 15h return 4GiB RAM?

Posted: Wed Apr 17, 2013 2:19 pm
by CWood
I'd hazard a guess as to say that the higher regions (type 0x02) are probably memory mapped devices, PCI et al. Can't be sure though.

Re: Why int 15h return 4GiB RAM?

Posted: Wed Apr 17, 2013 3:46 pm
by Brendan
Hi,

Decoded:
  • 0x00000000 to 0x0009F800 = 638 KiB of usable RAM
  • 0x0009F800 to 0x000A0000 = 2 KiB of "system" (EBDA)
  • 0x000A0000 to 0x000DC000 = 240 KiB not mentioned at all (legacy video area and some "unused")
  • 0x000DC000 to 0x00100000 = 144 KiB of "system" (device ROMs and legacy BIOS ROM area)
  • 0x00100000 to 0x03EF0000 = 63424 KiB of usable RAM
  • 0x03EF0000 to 0x03EFF000 = 60 KiB of "ACPI reclaimable"
  • 0x03EFF000 to 0x03F00000 = 4 KiB of "ACPI NVS"
  • 0x03F00000 to 0x04000000 = 1024 KiB of usable RAM
  • 0x04000000 to 0xE0000000 = not mentioned at all (possibly used by memory mapped PCI devices)
  • 0xE0000000 to 0xF0000000 = "system" (this is probably video display memory and shouldn't be listed)
  • 0xF0000000 to 0xFEC00000 = not mentioned at all
  • 0xFEC00000 to 0xFEC10000 = "system" (IO APIC/s, HPET, etc)
  • 0xFEC10000 to 0xFEE00000 = not mentioned at all
  • 0xFEE00000 to 0xFEE01000 = "system" (local APIC)
  • 0xFEE01000 to 0xFFFE0000 = not mentioned at all
  • 0xFFFE0000 to 0xFFFFFFFF = "system" (the actual firmware ROM)
  • 0x0000000100000000 to 0xFFFFFFFFFFFFFFFF = not mentioned at all
This adds up to 65086 KiB of usable RAM (which doesn't include RAM that the firmware is using for various other things that isn't usable).

Out of 65536 KiB of RAM, that leaves 450 KiB that isn't usable. Here's where that 450 KiB is used:
  • 0x0009F800 to 0x000A0000 = 2 KiB of "system" (EBDA)
  • 0x000A0000 to 0x000DC000 = 240 KiB not mentioned at all (legacy video area and some "unused")
  • 0x000DC000 to 0x00100000 = 144 KiB of "system" (device ROMs and legacy BIOS ROM area)
  • 0x03EF0000 to 0x03EFF000 = 60 KiB of "ACPI reclaimable"
  • 0x03EFF000 to 0x03F00000 = 4 KiB of "ACPI NVS"
Notes:
  • The 638 KiB of usable RAM from 0x00000000 to 0x0009F800 includes the IVT and BDA. The first "almost 2 KiB" can't be used until after the OS stops using the BIOS.
  • The 60 KiB of "ACPI reclaimable" from 0x03EF0000 to 0x03EFF000 is RAM used for ACPI tables that the OS can use as normal RAM after it's finished with the ACPI tables.
  • For the area from 0x000A0000 to 0x000DC000; the first 128 KiB is used for the legacy video display area and typically has RAM underneath that is used by the firmware for SMM. The remaining 112 KiB is RAM that would've been used for device ROMs if they existed (e.g. SCSI controller, ethernet ROM, etc) but hasn't been used by devices (it is essentially wasted RAM, but with some trickery an OS could have something like a "motherboard driver" that converts this 112 KiB of RAM back into usable RAM by tweaking MTRRs).
  • It's extremely likely that the area from 0xE0000000 to 0xF0000000 is 1 GiB of video display memory; and also extremely likely that this is a bug. The ACPI specs say that areas used by memory mapped PCI devices (including video display memory) should not be listed by the BIOS. The problem with this is that some OSs will enumerate PCI buses and re-allocate resources; and see that 0xE0000000 to 0xF0000000 is reserved and (correctly) decide that this area can't be used by any memory mapped PCI device (including the video card).

Cheers,

Brendan