* grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function.

(grub_machine_mmap_iterate): Take low memory into account
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-01-10 17:51:06 +01:00
parent b1969b3049
commit c49849cc63
2 changed files with 27 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function.
(grub_machine_mmap_iterate): Take low memory into account
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com> 2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into

View file

@ -36,6 +36,22 @@ struct grub_machine_mmap_entry
} __attribute__((packed)); } __attribute__((packed));
/*
*
* grub_get_conv_memsize(i) : return the conventional memory size in KB.
* BIOS call "INT 12H" to get conventional memory size
* The return value in AX.
*/
static inline grub_uint16_t
grub_get_conv_memsize (void)
{
struct grub_bios_int_registers regs;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x12, &regs);
return regs.eax & 0xffff;
}
/* /*
* grub_get_ext_memsize() : return the extended memory size in KB. * grub_get_ext_memsize() : return the extended memory size in KB.
* BIOS call "INT 15H, AH=88H" to get extended memory size * BIOS call "INT 15H, AH=88H" to get extended memory size
@ -155,6 +171,10 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
{ {
grub_uint32_t eisa_mmap = grub_get_eisa_mmap (); grub_uint32_t eisa_mmap = grub_get_eisa_mmap ();
if (hook (0x0, ((grub_uint32_t) grub_get_conv_memsize ()) << 10,
GRUB_MEMORY_AVAILABLE))
return 0;
if (eisa_mmap) if (eisa_mmap)
{ {
if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10, if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10,
@ -162,7 +182,8 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE); hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE);
} }
else else
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MEMORY_AVAILABLE); hook (0x100000, ((grub_uint32_t) grub_get_ext_memsize ()) << 10,
GRUB_MEMORY_AVAILABLE);
} }
return 0; return 0;