Questions on boot-time memory detection
Posted: Wed May 30, 2012 6:20 pm
I've got a few questions about detecting memory:
1) First off, can I generally assume that the high memory area (FFFF:10 - FFFF:FFFF in real mode, 100000 - 10FFF0 physical in protected mode) will be available if the machine in question has any extended memory at all? My bootloader currently assumes that the HMA exists (it loads the payload, as well as the Int 0x15 eax=E820 memory map, into the HMA), and this works on my two test machines and in Bochs, but is this a safe assumption? Are machines that violate it rare/old enough that I can simply decide not to support them, or should I keep my working area entirely under the 640k mark until I've processed the memory map?
2)When cleaning up the E820 memory map, the Wiki recommends changing overlapping areas to the most restrictive type. I'm not entirely clear, though, on which types are most restrictive. Type-1 (usable memory) is certainly the least restrictive, and type-3 (ACPI reclaimable) seems to be next. But what order should I place types 2, 4, and 5 in?
3)I've been looking through the E820 map sanitization function in the Linux kernel (sanitize_e820_map in arch/x86/kernel), and it returns non-success on being passed a map with only one entry (the specific case is "if (*pnr_map < 2)"). Is this based on an assumption that a map with only one entry is certain to be invalid (Presumably because the BIOS is certain to account for at least one type-2 entry and there has to be at least one type-1 entry to have any space to execute non-BIOS code in)?
1) First off, can I generally assume that the high memory area (FFFF:10 - FFFF:FFFF in real mode, 100000 - 10FFF0 physical in protected mode) will be available if the machine in question has any extended memory at all? My bootloader currently assumes that the HMA exists (it loads the payload, as well as the Int 0x15 eax=E820 memory map, into the HMA), and this works on my two test machines and in Bochs, but is this a safe assumption? Are machines that violate it rare/old enough that I can simply decide not to support them, or should I keep my working area entirely under the 640k mark until I've processed the memory map?
2)When cleaning up the E820 memory map, the Wiki recommends changing overlapping areas to the most restrictive type. I'm not entirely clear, though, on which types are most restrictive. Type-1 (usable memory) is certainly the least restrictive, and type-3 (ACPI reclaimable) seems to be next. But what order should I place types 2, 4, and 5 in?
3)I've been looking through the E820 map sanitization function in the Linux kernel (sanitize_e820_map in arch/x86/kernel), and it returns non-success on being passed a map with only one entry (the specific case is "if (*pnr_map < 2)"). Is this based on an assumption that a map with only one entry is certain to be invalid (Presumably because the BIOS is certain to account for at least one type-2 entry and there has to be at least one type-1 entry to have any space to execute non-BIOS code in)?