Hi,
At the moment I use bios interrupt 0x15/0xe820 to get a nice memory map for multiboot compatibility. But what if that interrupt fails..? Then I should use bios int 0x12 icw 0x15/0x801.. But how am I going to make a nice multiboot structure of the bunch information those interrupts returned?
-- Bietje
memory map from bios
Re: memory map from bios
Think about your range of target audience before adding support to legacy machines.
According to the wiki for the E820 function:
If you want to try other method anyway, take a look at http://wiki.osdev.org/Detecting_Memory_(x86)
According to the wiki for the E820 function:
IMO if that fail, it is totally acceptable to just panic.This function is available on all PCs built since 2002, and on most existing PCs before then. It is the only BIOS function that can detect memory areas above 4G. It is meant to be the ultimate memory detection BIOS function.
If you want to try other method anyway, take a look at http://wiki.osdev.org/Detecting_Memory_(x86)
What so difficult to put information into a data structure?Bietje wrote:But how am I going to make a nice multiboot structure of the bunch information those interrupts returned?
Re: memory map from bios
Nothing. But maby I worded my question wrong.. I don't really understand what the exact output is of 0x15/0xe801.bluemoon wrote:What so difficult to put information into a data structure?Bietje wrote:But how am I going to make a nice multiboot structure of the bunch information those interrupts returned?
What I understand is that it returns a number representing the extended (??) memory between 1m and 16m and the extended (??) memory above 16m.This function has been around since about 1994, so all systems from after then up to now should have this function. It is built to handle the 15M memory hole, but stops at the next hole / memory mapped device / reserved area above that. That is, it is only designed to handle contiguous memory above 16M.
Typical Output:
AX = CX = extended memory between 1M and 16M, in K (max 3C00h = 15MB)
BX = DX = extended memory above 16M, in 64K blocks
So my problem was how do I fill an entry/more entries with just that information?
Entry struct:
Code: Select all
mm_entry:
dd 0 ; size
dq 0 ; base address
dq 0 ; length
dd 0 ; type
Re: memory map from bios
An entry made with INT12 & E801 may look like this:
Code: Select all
Low = INT12 to detect low memory
Mid = extended memory between 1M and 16M
High = extended memory above 16M
Base Address | Length | Type
0x0000000000000000 | Low | Free Memory (1)
Low | 1M - Low | Reserved Memory
0x0000000000100000 | Mid | Free Memory between 1M and 16M
0x0000000001000000 | High | Free Memory above 16M
Translate into your structure:
entry[0].size = 20; // I guess size means the field size return by E820?
entry[0].base = 0;
entry[0].length = Low;
entry[0].type = kFree;
entry[1].size = 20;
entry[1].base = Low;
entry[1].length = 1M - Low;
entry[1].type = kReserved;
entry[2].size = 20;
entry[2].base = 1M;
entry[2].length = Mid;
entry[2].type = kFree;
entry[3].size = 20;
entry[3].base = 16M;
entry[3].length = High;
entry[3].type = kFree;
Re: memory map from bios
Aaah! Great, thank you! I will try to work that out now.
Re: memory map from bios
Is the type field just an integer?
Where a 1 represents type 1, 2 type 2, etc.. Or is it a bit more complicated?
- Type 1: Usable (normal) RAM
Type 2: Reserved - unusable
Type 3: ACPI reclaimable memory
Type 4: ACPI NVS memory
Type 5: Area containing bad memory
Re: memory map from bios
Hi,
Cheers,
Brendan
I'd consider it a 32-bit unsigned integer or a "uint32_t" (not an "int" or a "long" or a "short" or a "size_t" or....).Bietje wrote:Is the type field just an integer?
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.