A Question about ARDS (Address Range Descriptor Struct)
A Question about ARDS (Address Range Descriptor Struct)
Well, does anybody know the types of ARDS?
I've only known 01h and 02h.
If anybody knows a lot about any other knowledge of it, please teach me as well.
Thanks a lot.
I've only known 01h and 02h.
If anybody knows a lot about any other knowledge of it, please teach me as well.
Thanks a lot.
Doing steadfastly, or doing nil.
Re: A Question about ARDS (Address Range Descriptor Struct)
Hi,
The nice thing about languages like C is that anyone can define a structure called ARDS and put anything they feel like in it.
Cheers,
Brendan
Could you be a little more specific?XuQihang wrote:Well, does anybody know the types of ARDS?
I've only known 01h and 02h.
If anybody knows a lot about any other knowledge of it, please teach me as well.
The nice thing about languages like C is that anyone can define a structure called ARDS and put anything they feel like in it.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: A Question about ARDS (Address Range Descriptor Struct)
INT 15h, AX=E820h: ES:DI Pointer to an Address Range Descriptor structure which the BIOS is to fill in.
Re: A Question about ARDS (Address Range Descriptor Struct)
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.Brendan wrote:Hi,
Could you be a little more specific?XuQihang wrote:Well, does anybody know the types of ARDS?
I've only known 01h and 02h.
If anybody knows a lot about any other knowledge of it, please teach me as well.
The nice thing about languages like C is that anyone can define a structure called ARDS and put anything they feel like in it.
Cheers,
Brendan
Can you help me? If you don't mind, I'll be very grateful.
Doing steadfastly, or doing nil.
Re: A Question about ARDS (Address Range Descriptor Struct)
And after I got it, how to catch the information in it?alexfru wrote:INT 15h, AX=E820h: ES:DI Pointer to an Address Range Descriptor structure which the BIOS is to fill in.
Thanks if you don't mind telling me about it.
Doing steadfastly, or doing nil.
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: A Question about ARDS (Address Range Descriptor Struct)
Code: Select all
struct e820_entry
{
uint64_t base;
uint64_t length;
uint32_t type;
uint32_t acpi3;
}__attribute__((packed))
length is the 64-bit length of the physical memory located at base.
type can be one of several values. 1 means "available" or usable RAM. 2 means hardware-reserved. 3 means hardware-reserved until you've saved the ACPI tables. 4 means ACPI memory that must be preserved during sleep states. 5 means the memory contains errors. All other values should be treated as type 2. You shouldn't allow your physical memory manager to allocate memory except those that are marked 1 or "free for use."
acpi3 may or may not be present. If the function returned 20 bytes, then this field is not present. If it returned 24 bytes, then it is present. It is a bitfield, but I'm not sure what exactly it contains. You can find out from the ACPI spec.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: A Question about ARDS (Address Range Descriptor Struct)
Hi,
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:
Cheers,
Brendan
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).XuQihang wrote: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.Brendan wrote:Could you be a little more specific?
Can you help me? If you don't mind, I'll be very grateful.
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.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: A Question about ARDS (Address Range Descriptor Struct)
Now I can successfully get the data in ARDS.
Then would you mind telling me how to calculate the memory size?
Then would you mind telling me how to calculate the memory size?
- Attachments
-
- The capture of my incomplete OS.
- capture.png (7.18 KiB) Viewed 3880 times
Doing steadfastly, or doing nil.
Re: A Question about ARDS (Address Range Descriptor Struct)
Don't you have it now? It's in your picture.XuQihang wrote:Now I can successfully get the data in ARDS.
Then would you mind telling me how to calculate the memory size?
Re: A Question about ARDS (Address Range Descriptor Struct)
Well, I means, the total memory size.alexfru wrote: Don't you have it now? It's in your picture.
I use VMware and I allocate 5 GB Memory for the vm, but the calculation result is greater than 5 GB.
I don't know what goes wrong.
Doing steadfastly, or doing nil.
Re: A Question about ARDS (Address Range Descriptor Struct)
I think you shouldn't be adding sizes of areas other than type 1. And also 1 GB probably means 1,073,741,824 and not 1,000,000,000.XuQihang wrote: I use VMware and I allocate 5 GB Memory for the vm, but the calculation result is greater than 5 GB.
I don't know what goes wrong.
Re: A Question about ARDS (Address Range Descriptor Struct)
Well, I've done what you say. However, the result isn't 5 GB again.alexfru wrote:
I think you shouldn't be adding sizes of areas other than type 1. And also 1 GB probably means 1,073,741,824 and not 1,000,000,000.
5 GB is 1_4000_0000h, but the result is 1_3FF8_F800h. It's 7_0800h lower.
Doing steadfastly, or doing nil.
Re: A Question about ARDS (Address Range Descriptor Struct)
For best performance on x86 (and others) don't pack already "packed" structs.omarrx024 wrote:Code: Select all
struct e820_entry { uint64_t base; uint64_t length; uint32_t type; uint32_t acpi3; }__attribute__((packed))
Why you shouldn’t use __attribute__((packed))
Re: A Question about ARDS (Address Range Descriptor Struct)
Hi,
Cheers,
Brendan
That depends on which memory size you want:XuQihang wrote:Then would you mind telling me how to calculate the memory size?
- For "amount of currently usable RAM", add up the lengths for each area reported as "type = 1"
- For "amount of currently free and usable RAM", get the "amount of currently usable RAM" and subtract whatever your OS is already using and subtract the estimated size of the BIOS Data Area (e.g. "about 1.5 Kib" or maybe 4 KiB).
- For "amount of total usable RAM", add up the lengths for each area reported as "type = 1" or "type = 3" (the ACPI reclaimable areas that become usable after you reclaim them).
- For "amount of RAM installed", it's impossible to figure this out reliably from the memory map because the chipset and BIOS can steal RAM for various purposes (integrated video, memory for SMM, etc) and can also relocate areas (e.g. to make space for the "PCI hole" below 4 GiB). Instead, you need to get this information from the firmware's SMBIOS tables.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.