diff --git a/include/grub/i386/pc/init.h b/include/grub/i386/pc/init.h index 368668922..7dc8ee1f4 100644 --- a/include/grub/i386/pc/init.h +++ b/include/grub/i386/pc/init.h @@ -23,10 +23,6 @@ #include #include -/* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB - in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. */ -grub_uint32_t grub_get_eisa_mmap (void); - /* Get a memory map entry. Return next continuation value. Zero means the end. */ grub_uint32_t grub_get_mmap_entry (struct grub_machine_mmap_entry *entry, diff --git a/kern/i386/pc/mmap.c b/kern/i386/pc/mmap.c index b1bf2056f..2758d17f8 100644 --- a/kern/i386/pc/mmap.c +++ b/kern/i386/pc/mmap.c @@ -34,10 +34,33 @@ grub_get_ext_memsize (void) struct grub_bios_int_registers regs; regs.eax = 0x8800; + regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x15, ®s); return regs.eax & 0xffff; } +/* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB + in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. If error, return zero. + BIOS call "INT 15H, AH=E801H" to get EISA memory map, + AX = memory between 1M and 16M in 1K parts. + BX = memory above 16M in 64K parts. +*/ + +static inline grub_uint32_t +grub_get_eisa_mmap (void) +{ + struct grub_bios_int_registers regs; + + regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; + regs.eax = 0xe801; + grub_bios_interrupt (0x15, ®s); + + if ((regs.eax & 0xff00) == 0x8600) + return 0; + + return (regs.eax & 0xffff) | (regs.ebx << 16); +} + grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)) { diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index 233ab8074..3fa1b11e8 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -505,43 +505,6 @@ FUNCTION(grub_chainloader_real_boot) #include "../loader.S" -/* - * - * grub_get_eisa_mmap() : return packed EISA memory map, lower 16 bits is - * memory between 1M and 16M in 1K parts, upper 16 bits is - * memory above 16M in 64K parts. If error, return zero. - * BIOS call "INT 15H, AH=E801H" to get EISA memory map, - * AX = memory between 1M and 16M in 1K parts. - * BX = memory above 16M in 64K parts. - * - */ - -FUNCTION(grub_get_eisa_mmap) - pushl %ebp - pushl %ebx - - call prot_to_real /* enter real mode */ - .code16 - - movw $0xe801, %ax - int $0x15 - - shll $16, %ebx - movw %ax, %bx - - DATA32 call real_to_prot - .code32 - - cmpb $0x86, %bh - je xnoteisa - - movl %ebx, %eax - -xnoteisa: - popl %ebx - popl %ebp - ret - /* * * grub_get_mmap_entry(addr, cont) : address and old continuation value (zero to