intwrap get_memsize
This commit is contained in:
parent
77356db852
commit
c663074e6d
4 changed files with 36 additions and 46 deletions
|
@ -23,10 +23,6 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/machine/memory.h>
|
||||
|
||||
/* Get the memory size in KB. If EXTENDED is zero, return conventional
|
||||
memory, otherwise return extended memory. */
|
||||
grub_uint16_t grub_get_memsize (int extended);
|
||||
|
||||
/* 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);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/int.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
|
@ -134,6 +135,22 @@ compact_mem_regions (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* 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, ®s);
|
||||
return regs.eax & 0xffff;
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
|
@ -143,7 +160,7 @@ grub_machine_init (void)
|
|||
/* Initialize the console as early as possible. */
|
||||
grub_console_init ();
|
||||
|
||||
grub_lower_mem = grub_get_memsize (0) << 10;
|
||||
grub_lower_mem = grub_get_conv_memsize () << 10;
|
||||
|
||||
/* Sanity check. */
|
||||
if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END)
|
||||
|
|
|
@ -17,10 +17,27 @@
|
|||
*/
|
||||
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/int.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
/*
|
||||
* grub_get_ext_memsize() : return the extended memory size in KB.
|
||||
* BIOS call "INT 15H, AH=88H" to get extended memory size
|
||||
* The return value in AX.
|
||||
*
|
||||
*/
|
||||
static inline grub_uint16_t
|
||||
grub_get_ext_memsize (void)
|
||||
{
|
||||
struct grub_bios_int_registers regs;
|
||||
|
||||
regs.eax = 0x8800;
|
||||
grub_bios_interrupt (0x15, ®s);
|
||||
return regs.eax & 0xffff;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
||||
{
|
||||
|
@ -56,7 +73,7 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
}
|
||||
else
|
||||
hook (0x100000, grub_get_memsize (1) << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -505,46 +505,6 @@ FUNCTION(grub_chainloader_real_boot)
|
|||
|
||||
#include "../loader.S"
|
||||
|
||||
/*
|
||||
*
|
||||
* grub_get_memsize(i) : return the memory size in KB. i == 0 for conventional
|
||||
* memory, i == 1 for extended memory
|
||||
* BIOS call "INT 12H" to get conventional memory size
|
||||
* BIOS call "INT 15H, AH=88H" to get extended memory size
|
||||
* Both have the return value in AX.
|
||||
*
|
||||
*/
|
||||
|
||||
FUNCTION(grub_get_memsize)
|
||||
pushl %ebp
|
||||
|
||||
movl %eax, %edx
|
||||
|
||||
call prot_to_real /* enter real mode */
|
||||
.code16
|
||||
|
||||
testl %edx, %edx
|
||||
jnz xext
|
||||
|
||||
int $0x12
|
||||
jmp xdone
|
||||
|
||||
xext:
|
||||
movb $0x88, %ah
|
||||
int $0x15
|
||||
|
||||
xdone:
|
||||
movw %ax, %dx
|
||||
|
||||
DATA32 call real_to_prot
|
||||
.code32
|
||||
|
||||
movw %dx, %ax
|
||||
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* grub_get_eisa_mmap() : return packed EISA memory map, lower 16 bits is
|
||||
|
|
Loading…
Reference in a new issue