Hi,
XuQihang wrote:
Brendan wrote:
Could you be a little more specific?
I means, I want to get memory information by calling BIOS (16 Bits Assembler). I've heard the way is 'mov ax, 0E820h' and 'int 15h'. Some book wrote after calling the pointer of ARDS is stored in 'es:di'. Now I can get ARDS, but I don't know the detailed structure of ARDS.
Can you help me? If you don't mind, I'll be very grateful.
This is part of the ACPI specification now (since the first version of the ACPI specification); and the ACPI specification/s gives complete details (including the extension that increased the structure's size to 24 bytes and the flags that were added, and all the new types, etc). I'd recommend downloading at least the most recent version of the ACPI specification (and every version of the ACPI specification if you can, so you can figure out what was added when).
For old information (including information for computers that existed before the first version of ACPI) see
the corresponding entry in Ralph Brown's Interrupt List.
Note that:
- The raw data from "int 0x15, eax=0xE820" should be sanitised; including merging adjacent areas of the same type and attributes, handling areas that are misreported as overlapping, and possibly sorting it in a sane order.
- The memory map you get from UEFI is quite different (different types, additional "cacheability" information, etc).
- If you support very old computers (that don't support "int 0x15, eax=0xE820") it's possible to fabricate equivelent information from older BIOS functions (but takes some care).
- None of the memory maps from firmware (from UEFI, from BIOS "int 0x15, eax=0xE820", or fabricated from older BIOS functions) include:
- information about NUMA domains (can be obtained from ACPI's tables)
- "hot-plug RAM" areas (can be obtained from ACPI's tables)
- the physical address space size (can be obtained from CPUID)
- which areas are/aren't usable for memory mapped PCI devices (can be derived from other information and "guesswork")
- which areas are currently being used by memory mapped PCI devices (can be derived from PCI configuration space)
- how physical memory areas relate to "motherboard RAM slots" and what type of RAM is involved and if it's ECC or not (can only be partially obtained from SMBIOS tables - you need a motherboard chipset to figure it out properly).
- The memory maps from BIOS (from BIOS "int 0x15, eax=0xE820", or fabricated from older BIOS functions) don't include cacheability information (but the memory map from UEFI does). You could obtain this information on BIOS systems by extracting it directly from the CPU's MTRRs.
For these reasons I recommend inventing your own "memory map entry structure", and converting whatever the firmware gives you into your own format, and then merging all the other information (from other places) into that structure. If you do this right, you can end up with a "standard for your OS" memory map (regardless of what the firmware was) that contains all relevant information in one place.
Cheers,
Brendan