Unify memory types.
* grub-core/Makefile.am (KERNEL_HEADER_FILES): Include memory.h. * grub-core/commands/lsmmap.c (grub_cmd_lsmmap): Output user-readable types. * grub-core/kern/i386/multiboot_mmap.c (grub_lower_mem): Removed. (grub_upper_mem): Likewise. * grub-core/kern/ieee1275/init.c (grub_upper_mem): Likewise. * include/grub/memory.h (grub_memory_type_t): New enum. All users updated.
This commit is contained in:
commit
a1d84a5e5e
52 changed files with 315 additions and 443 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2010-09-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Unify memory types.
|
||||||
|
|
||||||
|
* grub-core/Makefile.am (KERNEL_HEADER_FILES): Include memory.h.
|
||||||
|
* grub-core/commands/lsmmap.c (grub_cmd_lsmmap): Output user-readable
|
||||||
|
types.
|
||||||
|
* grub-core/kern/i386/multiboot_mmap.c (grub_lower_mem): Removed.
|
||||||
|
(grub_upper_mem): Likewise.
|
||||||
|
* grub-core/kern/ieee1275/init.c (grub_upper_mem): Likewise.
|
||||||
|
* include/grub/memory.h (grub_memory_type_t): New enum.
|
||||||
|
All users updated.
|
||||||
|
|
||||||
2010-09-18 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-09-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/Makefile.core.def (lsapm): New module.
|
* grub-core/Makefile.core.def (lsapm): New module.
|
||||||
|
|
|
@ -75,9 +75,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
|
||||||
|
|
||||||
if COND_i386_pc
|
if COND_i386_pc
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
|
||||||
|
@ -93,24 +93,20 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COND_i386_coreboot
|
if COND_i386_coreboot
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COND_i386_multiboot
|
if COND_i386_multiboot
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COND_i386_qemu
|
if COND_i386_qemu
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COND_i386_ieee1275
|
if COND_i386_ieee1275
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
endif
|
endif
|
||||||
|
@ -124,7 +120,6 @@ endif
|
||||||
|
|
||||||
if COND_mips_yeeloong
|
if COND_mips_yeeloong
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
|
||||||
|
@ -135,7 +130,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
||||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
|
||||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/serial.h
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COND_powerpc_ieee1275
|
if COND_powerpc_ieee1275
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/i386/pc/memory.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/acpi.h>
|
#include <grub/acpi.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
|
@ -151,10 +150,10 @@ grub_acpi_create_ebda (void)
|
||||||
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
||||||
grub_uint32_t);
|
grub_uint32_t);
|
||||||
int NESTED_FUNC_ATTR find_hook (grub_uint64_t start, grub_uint64_t size,
|
int NESTED_FUNC_ATTR find_hook (grub_uint64_t start, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
grub_uint64_t end = start + size;
|
grub_uint64_t end = start + size;
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (end > 0x100000)
|
if (end > 0x100000)
|
||||||
end = 0x100000;
|
end = 0x100000;
|
||||||
|
@ -180,7 +179,7 @@ grub_acpi_create_ebda (void)
|
||||||
"couldn't find space for the new EBDA");
|
"couldn't find space for the new EBDA");
|
||||||
|
|
||||||
mmapregion = grub_mmap_register (PTR_TO_UINT64 (targetebda), ebda_len,
|
mmapregion = grub_mmap_register (PTR_TO_UINT64 (targetebda), ebda_len,
|
||||||
GRUB_MACHINE_MEMORY_RESERVED);
|
GRUB_MEMORY_RESERVED);
|
||||||
if (! mmapregion)
|
if (! mmapregion)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
|
@ -704,7 +703,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
||||||
|
|
||||||
playground = playground_ptr
|
playground = playground_ptr
|
||||||
= grub_mmap_malign_and_register (1, playground_size, &mmapregion,
|
= grub_mmap_malign_and_register (1, playground_size, &mmapregion,
|
||||||
GRUB_MACHINE_MEMORY_ACPI, 0);
|
GRUB_MEMORY_ACPI, 0);
|
||||||
|
|
||||||
if (! playground)
|
if (! playground)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,9 +24,10 @@
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/loader.h>
|
#include <grub/loader.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/machine/biosnum.h>
|
#include <grub/machine/biosnum.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
|
#include <grub/machine/memory.h>
|
||||||
|
|
||||||
|
|
||||||
/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
|
/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
|
||||||
|
@ -306,7 +307,7 @@ install_int13_handler (int noret __attribute__ ((unused)))
|
||||||
grub_dprintf ("drivemap", "Payload is %u bytes long\n", total_size);
|
grub_dprintf ("drivemap", "Payload is %u bytes long\n", total_size);
|
||||||
handler_base = grub_mmap_malign_and_register (16, total_size,
|
handler_base = grub_mmap_malign_and_register (16, total_size,
|
||||||
&drivemap_mmap,
|
&drivemap_mmap,
|
||||||
GRUB_MACHINE_MEMORY_RESERVED,
|
GRUB_MEMORY_RESERVED,
|
||||||
GRUB_MMAP_MALLOC_LOW);
|
GRUB_MMAP_MALLOC_LOW);
|
||||||
if (! handler_base)
|
if (! handler_base)
|
||||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't reserve "
|
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't reserve "
|
||||||
|
|
|
@ -16,22 +16,37 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GRUB_MACHINE_EMU
|
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#endif
|
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
|
|
||||||
|
static const char *names[] =
|
||||||
|
{
|
||||||
|
[GRUB_MEMORY_AVAILABLE] = "available",
|
||||||
|
[GRUB_MEMORY_RESERVED] = "reserved",
|
||||||
|
[GRUB_MEMORY_ACPI] = "ACPI reclamaible",
|
||||||
|
[GRUB_MEMORY_NVS] = "NVS",
|
||||||
|
[GRUB_MEMORY_BADRAM] = "BadRAM",
|
||||||
|
[GRUB_MEMORY_CODE] = "firmware code",
|
||||||
|
[GRUB_MEMORY_HOLE] = "hole"
|
||||||
|
};
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
|
grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
|
int argc __attribute__ ((unused)),
|
||||||
|
char **args __attribute__ ((unused)))
|
||||||
|
|
||||||
{
|
{
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
|
if (type < ARRAY_SIZE (names) && names[type])
|
||||||
|
grub_printf ("base_addr = 0x%llx, length = 0x%llx, %s\n",
|
||||||
|
(long long) addr, (long long) size, names[type]);
|
||||||
|
else
|
||||||
grub_printf ("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n",
|
grub_printf ("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n",
|
||||||
(long long) addr, (long long) size, type);
|
(long long) addr, (long long) size, type);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/biosdisk.h>
|
#include <grub/machine/biosdisk.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/machine/int.h>
|
#include <grub/machine/int.h>
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/efiemu/efiemu.h>
|
#include <grub/efiemu/efiemu.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
|
|
||||||
struct grub_efiemu_memrequest
|
struct grub_efiemu_memrequest
|
||||||
{
|
{
|
||||||
|
@ -269,10 +269,11 @@ static grub_err_t
|
||||||
grub_efiemu_mmap_init (void)
|
grub_efiemu_mmap_init (void)
|
||||||
{
|
{
|
||||||
auto int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t, grub_uint64_t,
|
auto int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t, grub_uint64_t,
|
||||||
grub_uint32_t);
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t addr __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type
|
||||||
|
__attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
mmap_reserved_size++;
|
mmap_reserved_size++;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -382,32 +383,29 @@ grub_efiemu_mm_init (void)
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_efiemu_mmap_fill (void)
|
grub_efiemu_mmap_fill (void)
|
||||||
{
|
{
|
||||||
auto int NESTED_FUNC_ATTR fill_hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR fill_hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr,
|
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr,
|
||||||
grub_uint64_t size,
|
grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
case GRUB_MEMORY_AVAILABLE:
|
||||||
return grub_efiemu_add_to_mmap (addr, size,
|
return grub_efiemu_add_to_mmap (addr, size,
|
||||||
GRUB_EFI_CONVENTIONAL_MEMORY);
|
GRUB_EFI_CONVENTIONAL_MEMORY);
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
case GRUB_MEMORY_ACPI:
|
||||||
case GRUB_MACHINE_MEMORY_ACPI:
|
|
||||||
return grub_efiemu_add_to_mmap (addr, size,
|
return grub_efiemu_add_to_mmap (addr, size,
|
||||||
GRUB_EFI_ACPI_RECLAIM_MEMORY);
|
GRUB_EFI_ACPI_RECLAIM_MEMORY);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
case GRUB_MEMORY_NVS:
|
||||||
case GRUB_MACHINE_MEMORY_NVS:
|
|
||||||
return grub_efiemu_add_to_mmap (addr, size,
|
return grub_efiemu_add_to_mmap (addr, size,
|
||||||
GRUB_EFI_ACPI_MEMORY_NVS);
|
GRUB_EFI_ACPI_MEMORY_NVS);
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
grub_printf ("Unknown memory type %d. Marking as unusable\n", type);
|
grub_printf ("Unknown memory type %d. Assuming unusable\n", type);
|
||||||
case GRUB_MACHINE_MEMORY_RESERVED:
|
case GRUB_MEMORY_RESERVED:
|
||||||
return grub_efiemu_add_to_mmap (addr, size,
|
return grub_efiemu_add_to_mmap (addr, size,
|
||||||
GRUB_EFI_UNUSABLE_MEMORY);
|
GRUB_EFI_UNUSABLE_MEMORY);
|
||||||
}
|
}
|
||||||
|
@ -421,9 +419,7 @@ grub_efiemu_mmap_fill (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
grub_efiemu_mmap_iterate (grub_memory_hook_t hook)
|
||||||
grub_uint64_t,
|
|
||||||
grub_uint32_t))
|
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
@ -432,18 +428,22 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
{
|
{
|
||||||
case GRUB_EFI_RUNTIME_SERVICES_CODE:
|
case GRUB_EFI_RUNTIME_SERVICES_CODE:
|
||||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||||
GRUB_EFIEMU_MEMORY_CODE);
|
GRUB_MEMORY_CODE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GRUB_EFI_UNUSABLE_MEMORY:
|
||||||
|
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||||
|
GRUB_MEMORY_BADRAM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_RESERVED_MEMORY_TYPE:
|
case GRUB_EFI_RESERVED_MEMORY_TYPE:
|
||||||
case GRUB_EFI_RUNTIME_SERVICES_DATA:
|
case GRUB_EFI_RUNTIME_SERVICES_DATA:
|
||||||
case GRUB_EFI_UNUSABLE_MEMORY:
|
|
||||||
case GRUB_EFI_MEMORY_MAPPED_IO:
|
case GRUB_EFI_MEMORY_MAPPED_IO:
|
||||||
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
||||||
case GRUB_EFI_PAL_CODE:
|
case GRUB_EFI_PAL_CODE:
|
||||||
case GRUB_EFI_MAX_MEMORY_TYPE:
|
case GRUB_EFI_MAX_MEMORY_TYPE:
|
||||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||||
GRUB_EFIEMU_MEMORY_RESERVED);
|
GRUB_MEMORY_RESERVED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_LOADER_CODE:
|
case GRUB_EFI_LOADER_CODE:
|
||||||
|
@ -452,17 +452,17 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
case GRUB_EFI_BOOT_SERVICES_DATA:
|
case GRUB_EFI_BOOT_SERVICES_DATA:
|
||||||
case GRUB_EFI_CONVENTIONAL_MEMORY:
|
case GRUB_EFI_CONVENTIONAL_MEMORY:
|
||||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||||
GRUB_EFIEMU_MEMORY_AVAILABLE);
|
GRUB_MEMORY_AVAILABLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
|
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
|
||||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||||
GRUB_EFIEMU_MEMORY_ACPI);
|
GRUB_MEMORY_ACPI);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_ACPI_MEMORY_NVS:
|
case GRUB_EFI_ACPI_MEMORY_NVS:
|
||||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||||
GRUB_EFIEMU_MEMORY_NVS);
|
GRUB_MEMORY_NVS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <grub/machine/time.h>
|
#include <grub/machine/time.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/machine/console.h>
|
#include <grub/machine/console.h>
|
||||||
|
#include <grub/offsets.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
@ -64,8 +65,10 @@ grub_machine_init (void)
|
||||||
/* Initialize the console as early as possible. */
|
/* Initialize the console as early as possible. */
|
||||||
grub_vga_text_init ();
|
grub_vga_text_init ();
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
#if GRUB_CPU_SIZEOF_VOID_P == 4
|
#if GRUB_CPU_SIZEOF_VOID_P == 4
|
||||||
/* Restrict ourselves to 32-bit memory space. */
|
/* Restrict ourselves to 32-bit memory space. */
|
||||||
|
@ -75,7 +78,7 @@ grub_machine_init (void)
|
||||||
size = GRUB_ULONG_MAX - addr;
|
size = GRUB_ULONG_MAX - addr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Avoid the lower memory. */
|
/* Avoid the lower memory. */
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
|
#include <grub/machine/lbio.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
@ -74,7 +75,7 @@ signature_found:
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
{
|
{
|
||||||
mem_region_t mem_region;
|
mem_region_t mem_region;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
/* For stack parameters. */
|
||||||
|
#include <grub/i386/pc/memory.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/cpu/linux.h>
|
#include <grub/cpu/linux.h>
|
||||||
#include <grub/offsets.h>
|
#include <grub/offsets.h>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/offsets.h>
|
||||||
#include <grub/cpu/linux.h>
|
#include <grub/cpu/linux.h>
|
||||||
#include <multiboot.h>
|
#include <multiboot.h>
|
||||||
#include <multiboot2.h>
|
#include <multiboot2.h>
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
|
||||||
grub_size_t grub_lower_mem, grub_upper_mem;
|
|
||||||
|
|
||||||
/* A pointer to the MBI in its initial location. */
|
/* A pointer to the MBI in its initial location. */
|
||||||
struct multiboot_info *startup_multiboot_info;
|
struct multiboot_info *startup_multiboot_info;
|
||||||
|
|
||||||
|
@ -56,21 +54,10 @@ grub_machine_mmap_init ()
|
||||||
}
|
}
|
||||||
grub_memmove (mmap_entries, (void *) kern_multiboot_info.mmap_addr, kern_multiboot_info.mmap_length);
|
grub_memmove (mmap_entries, (void *) kern_multiboot_info.mmap_addr, kern_multiboot_info.mmap_length);
|
||||||
kern_multiboot_info.mmap_addr = (grub_uint32_t) mmap_entries;
|
kern_multiboot_info.mmap_addr = (grub_uint32_t) mmap_entries;
|
||||||
|
|
||||||
if ((kern_multiboot_info.flags & MULTIBOOT_INFO_MEMORY) == 0)
|
|
||||||
{
|
|
||||||
grub_lower_mem = GRUB_MEMORY_MACHINE_LOWER_USABLE;
|
|
||||||
grub_upper_mem = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grub_lower_mem = kern_multiboot_info.mem_lower * 1024;
|
|
||||||
grub_upper_mem = kern_multiboot_info.mem_upper * 1024;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
{
|
{
|
||||||
struct multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr;
|
struct multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr;
|
||||||
|
|
||||||
|
|
|
@ -181,8 +181,10 @@ grub_machine_init (void)
|
||||||
grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END);
|
grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
/* Avoid the lower memory. */
|
/* Avoid the lower memory. */
|
||||||
if (addr < 0x100000)
|
if (addr < 0x100000)
|
||||||
|
@ -195,7 +197,7 @@ grub_machine_init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore >4GB. */
|
/* Ignore >4GB. */
|
||||||
if (addr <= 0xFFFFFFFF && type == GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (addr <= 0xFFFFFFFF && type == GRUB_MEMORY_AVAILABLE)
|
||||||
{
|
{
|
||||||
grub_size_t len;
|
grub_size_t len;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,20 @@
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
|
||||||
|
struct grub_machine_mmap_entry
|
||||||
|
{
|
||||||
|
grub_uint32_t size;
|
||||||
|
grub_uint64_t addr;
|
||||||
|
grub_uint64_t len;
|
||||||
|
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
||||||
|
#define GRUB_MACHINE_MEMORY_RESERVED 2
|
||||||
|
#define GRUB_MACHINE_MEMORY_ACPI 3
|
||||||
|
#define GRUB_MACHINE_MEMORY_NVS 4
|
||||||
|
#define GRUB_MACHINE_MEMORY_BADRAM 5
|
||||||
|
grub_uint32_t type;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
|
@ -109,7 +123,7 @@ grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
{
|
{
|
||||||
grub_uint32_t cont;
|
grub_uint32_t cont;
|
||||||
struct grub_machine_mmap_entry *entry
|
struct grub_machine_mmap_entry *entry
|
||||||
|
@ -124,9 +138,9 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (hook (entry->addr, entry->len,
|
if (hook (entry->addr, entry->len,
|
||||||
/* Multiboot mmaps have been defined to match with the E820 definition.
|
/* GRUB mmaps have been defined to match with the E820 definition.
|
||||||
Therefore, we can just pass type through. */
|
Therefore, we can just pass type through. */
|
||||||
entry->type))
|
((entry->type <= GRUB_MACHINE_MEMORY_BADRAM) && (entry->type >= GRUB_MACHINE_MEMORY_AVAILABLE)) ? entry->type : GRUB_MEMORY_RESERVED))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (! cont)
|
if (! cont)
|
||||||
|
@ -143,11 +157,12 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
||||||
|
|
||||||
if (eisa_mmap)
|
if (eisa_mmap)
|
||||||
{
|
{
|
||||||
if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10, GRUB_MACHINE_MEMORY_AVAILABLE) == 0)
|
if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10,
|
||||||
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MACHINE_MEMORY_AVAILABLE);
|
GRUB_MEMORY_AVAILABLE) == 0)
|
||||||
|
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
|
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MEMORY_AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <grub/i386/memory.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/cmos.h>
|
#include <grub/cmos.h>
|
||||||
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
#define QEMU_CMOS_MEMSIZE_HIGH 0x35
|
#define QEMU_CMOS_MEMSIZE_HIGH 0x35
|
||||||
#define QEMU_CMOS_MEMSIZE_LOW 0x34
|
#define QEMU_CMOS_MEMSIZE_LOW 0x34
|
||||||
|
@ -60,38 +62,38 @@ grub_machine_mmap_init ()
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
{
|
{
|
||||||
if (hook (0x0,
|
if (hook (0x0,
|
||||||
(grub_addr_t) _start,
|
(grub_addr_t) _start,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
GRUB_MEMORY_AVAILABLE))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (hook ((grub_addr_t) _end,
|
if (hook ((grub_addr_t) _end,
|
||||||
0xa0000 - (grub_addr_t) _end,
|
0xa0000 - (grub_addr_t) _end,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
GRUB_MEMORY_AVAILABLE))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (hook (GRUB_MEMORY_MACHINE_UPPER,
|
if (hook (GRUB_MEMORY_MACHINE_UPPER,
|
||||||
0x100000 - GRUB_MEMORY_MACHINE_UPPER,
|
0x100000 - GRUB_MEMORY_MACHINE_UPPER,
|
||||||
GRUB_MACHINE_MEMORY_RESERVED))
|
GRUB_MEMORY_RESERVED))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Everything else is free. */
|
/* Everything else is free. */
|
||||||
if (hook (0x100000,
|
if (hook (0x100000,
|
||||||
min (mem_size, (grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE) - 0x100000,
|
min (mem_size, (grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE) - 0x100000,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
GRUB_MEMORY_AVAILABLE))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Protect boot.img, which contains the gdt. It is mapped at the top of memory
|
/* Protect boot.img, which contains the gdt. It is mapped at the top of memory
|
||||||
(it is also mapped below 0x100000, but we already reserved that area). */
|
(it is also mapped below 0x100000, but we already reserved that area). */
|
||||||
if (hook ((grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE,
|
if (hook ((grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE,
|
||||||
GRUB_BOOT_MACHINE_SIZE,
|
GRUB_BOOT_MACHINE_SIZE,
|
||||||
GRUB_MACHINE_MEMORY_RESERVED))
|
GRUB_MEMORY_RESERVED))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (above_4g != 0 && hook (0x100000000ULL, above_4g,
|
if (above_4g != 0 && hook (0x100000000ULL, above_4g,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
GRUB_MEMORY_AVAILABLE))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
|
||||||
|
#include <grub/i386/pc/memory.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <grub/ieee1275/ofdisk.h>
|
#include <grub/ieee1275/ofdisk.h>
|
||||||
#include <grub/ieee1275/ieee1275.h>
|
#include <grub/ieee1275/ieee1275.h>
|
||||||
#include <grub/offsets.h>
|
#include <grub/offsets.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
|
|
||||||
/* The minimal heap size we can live with. */
|
/* The minimal heap size we can live with. */
|
||||||
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
|
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
|
||||||
|
@ -126,8 +127,10 @@ static void grub_claim_heap (void)
|
||||||
{
|
{
|
||||||
unsigned long total = 0;
|
unsigned long total = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type);
|
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len,
|
||||||
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type)
|
grub_memory_type_t type);
|
||||||
|
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != 1)
|
if (type != 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -189,31 +192,6 @@ static void grub_claim_heap (void)
|
||||||
grub_machine_mmap_iterate (heap_init);
|
grub_machine_mmap_iterate (heap_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __i386__
|
|
||||||
|
|
||||||
grub_uint32_t grub_upper_mem;
|
|
||||||
|
|
||||||
/* We need to call this before grub_claim_memory. */
|
|
||||||
static void
|
|
||||||
grub_get_extended_memory (void)
|
|
||||||
{
|
|
||||||
auto int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type);
|
|
||||||
int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type)
|
|
||||||
{
|
|
||||||
if (type == 1 && addr == 0x100000)
|
|
||||||
{
|
|
||||||
grub_upper_mem = len;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_machine_mmap_iterate (find_ext_mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static grub_uint64_t ieee1275_get_time_ms (void);
|
static grub_uint64_t ieee1275_get_time_ms (void);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -225,9 +203,6 @@ grub_machine_init (void)
|
||||||
grub_ieee1275_init ();
|
grub_ieee1275_init ();
|
||||||
|
|
||||||
grub_console_init_early ();
|
grub_console_init_early ();
|
||||||
#ifdef __i386__
|
|
||||||
grub_get_extended_memory ();
|
|
||||||
#endif
|
|
||||||
grub_claim_heap ();
|
grub_claim_heap ();
|
||||||
grub_console_init_lately ();
|
grub_console_init_lately ();
|
||||||
grub_ofdisk_init ();
|
grub_ofdisk_init ();
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/ieee1275/ieee1275.h>
|
#include <grub/ieee1275/ieee1275.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
{
|
{
|
||||||
grub_ieee1275_phandle_t root;
|
grub_ieee1275_phandle_t root;
|
||||||
grub_ieee1275_phandle_t memory;
|
grub_ieee1275_phandle_t memory;
|
||||||
|
@ -66,7 +66,7 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
||||||
if (size_cells == 2)
|
if (size_cells == 2)
|
||||||
size = (size << 32) | available[i++];
|
size = (size << 32) | available[i++];
|
||||||
|
|
||||||
if (hook (address, size, GRUB_MACHINE_MEMORY_AVAILABLE))
|
if (hook (address, size, GRUB_MEMORY_AVAILABLE))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,11 +51,8 @@ grub_reboot (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
grub_uint64_t,
|
|
||||||
grub_uint32_t))
|
|
||||||
{
|
{
|
||||||
hook (0, RAMSIZE,
|
hook (0, RAMSIZE, GRUB_MEMORY_AVAILABLE);
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <grub/time.h>
|
#include <grub/time.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
#include <grub/mips/loongson.h>
|
#include <grub/mips/loongson.h>
|
||||||
#include <grub/cs5536.h>
|
#include <grub/cs5536.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
|
@ -57,14 +58,12 @@ grub_get_rtc (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
grub_uint64_t,
|
|
||||||
grub_uint32_t))
|
|
||||||
{
|
{
|
||||||
hook (GRUB_ARCH_LOWMEMPSTART, grub_arch_memsize << 20,
|
hook (GRUB_ARCH_LOWMEMPSTART, grub_arch_memsize << 20,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
GRUB_MEMORY_AVAILABLE);
|
||||||
hook (GRUB_ARCH_HIGHMEMPSTART, grub_arch_highmemsize << 20,
|
hook (GRUB_ARCH_HIGHMEMPSTART, grub_arch_highmemsize << 20,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
GRUB_MEMORY_AVAILABLE);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ grub_relocator_firmware_get_max_events (void)
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
auto int NESTED_FUNC_ATTR count (grub_uint64_t addr __attribute__ ((unused)),
|
auto int NESTED_FUNC_ATTR count (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t len __attribute__ ((unused)),
|
grub_uint64_t len __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)));
|
grub_memory_type_t type __attribute__ ((unused)));
|
||||||
int NESTED_FUNC_ATTR count (grub_uint64_t addr __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR count (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t len __attribute__ ((unused)),
|
grub_uint64_t len __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -47,11 +47,11 @@ grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events)
|
||||||
{
|
{
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
auto int NESTED_FUNC_ATTR fill (grub_uint64_t addr, grub_uint64_t len,
|
auto int NESTED_FUNC_ATTR fill (grub_uint64_t addr, grub_uint64_t len,
|
||||||
grub_uint32_t type);
|
grub_memory_type_t type);
|
||||||
int NESTED_FUNC_ATTR fill (grub_uint64_t addr, grub_uint64_t len,
|
int NESTED_FUNC_ATTR fill (grub_uint64_t addr, grub_uint64_t len,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
|
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
|
||||||
|
|
|
@ -1379,11 +1379,13 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
|
||||||
|
|
||||||
{
|
{
|
||||||
int found = 0;
|
int found = 0;
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t sz, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t sz,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
grub_uint64_t candidate;
|
grub_uint64_t candidate;
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
candidate = ALIGN_UP (addr, align);
|
candidate = ALIGN_UP (addr, align);
|
||||||
if (candidate < min_addr)
|
if (candidate < min_addr)
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#include <grub/loader.h>
|
#include <grub/loader.h>
|
||||||
#include <grub/i386/bsd.h>
|
#include <grub/i386/bsd.h>
|
||||||
#include <grub/i386/cpuid.h>
|
#include <grub/i386/cpuid.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
|
#include <grub/i386/memory.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
@ -261,37 +261,30 @@ generate_e820_mmap (grub_size_t *len, grub_size_t *cnt, void *buf)
|
||||||
struct grub_e820_mmap *mmap = buf;
|
struct grub_e820_mmap *mmap = buf;
|
||||||
struct grub_e820_mmap prev, cur;
|
struct grub_e820_mmap prev, cur;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
cur.addr = addr;
|
cur.addr = addr;
|
||||||
cur.size = size;
|
cur.size = size;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
case GRUB_MEMORY_AVAILABLE:
|
||||||
cur.type = GRUB_E820_RAM;
|
cur.type = GRUB_E820_RAM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
case GRUB_MEMORY_ACPI:
|
||||||
case GRUB_MACHINE_MEMORY_ACPI:
|
|
||||||
cur.type = GRUB_E820_ACPI;
|
cur.type = GRUB_E820_ACPI;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
case GRUB_MEMORY_NVS:
|
||||||
case GRUB_MACHINE_MEMORY_NVS:
|
|
||||||
cur.type = GRUB_E820_NVS;
|
cur.type = GRUB_E820_NVS;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#ifdef GRUB_MACHINE_MEMORY_CODE
|
case GRUB_MEMORY_CODE:
|
||||||
case GRUB_MACHINE_MEMORY_CODE:
|
case GRUB_MEMORY_RESERVED:
|
||||||
#endif
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_RESERVED
|
|
||||||
case GRUB_MACHINE_MEMORY_RESERVED:
|
|
||||||
#endif
|
|
||||||
cur.type = GRUB_E820_RESERVED;
|
cur.type = GRUB_E820_RESERVED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/loader.h>
|
#include <grub/loader.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
|
@ -147,10 +146,11 @@ find_mmap_size (void)
|
||||||
{
|
{
|
||||||
grub_size_t count = 0, mmap_size;
|
grub_size_t count = 0, mmap_size;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -214,12 +214,14 @@ allocate_pages (grub_size_t prot_size)
|
||||||
/* FIXME: Should request low memory from the heap when this feature is
|
/* FIXME: Should request low memory from the heap when this feature is
|
||||||
implemented. */
|
implemented. */
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
/* We must put real mode code in the traditional space. */
|
/* We must put real mode code in the traditional space. */
|
||||||
|
|
||||||
if (type == GRUB_MACHINE_MEMORY_AVAILABLE
|
if (type == GRUB_MEMORY_AVAILABLE
|
||||||
&& addr <= 0x90000)
|
&& addr <= 0x90000)
|
||||||
{
|
{
|
||||||
if (addr < 0x10000)
|
if (addr < 0x10000)
|
||||||
|
@ -394,36 +396,32 @@ grub_linux_boot (void)
|
||||||
grub_dprintf ("linux", "code32_start = %x\n",
|
grub_dprintf ("linux", "code32_start = %x\n",
|
||||||
(unsigned) params->code32_start);
|
(unsigned) params->code32_start);
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
case GRUB_MEMORY_AVAILABLE:
|
||||||
grub_e820_add_region (params->e820_map, &e820_num,
|
grub_e820_add_region (params->e820_map, &e820_num,
|
||||||
addr, size, GRUB_E820_RAM);
|
addr, size, GRUB_E820_RAM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
case GRUB_MEMORY_ACPI:
|
||||||
case GRUB_MACHINE_MEMORY_ACPI:
|
|
||||||
grub_e820_add_region (params->e820_map, &e820_num,
|
grub_e820_add_region (params->e820_map, &e820_num,
|
||||||
addr, size, GRUB_E820_ACPI);
|
addr, size, GRUB_E820_ACPI);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
case GRUB_MEMORY_NVS:
|
||||||
case GRUB_MACHINE_MEMORY_NVS:
|
|
||||||
grub_e820_add_region (params->e820_map, &e820_num,
|
grub_e820_add_region (params->e820_map, &e820_num,
|
||||||
addr, size, GRUB_E820_NVS);
|
addr, size, GRUB_E820_NVS);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_CODE
|
case GRUB_MEMORY_CODE:
|
||||||
case GRUB_MACHINE_MEMORY_CODE:
|
|
||||||
grub_e820_add_region (params->e820_map, &e820_num,
|
grub_e820_add_region (params->e820_map, &e820_num,
|
||||||
addr, size, GRUB_E820_EXEC_CODE);
|
addr, size, GRUB_E820_EXEC_CODE);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
grub_e820_add_region (params->e820_map, &e820_num,
|
grub_e820_add_region (params->e820_map, &e820_num,
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
#ifdef GRUB_MACHINE_PCBIOS
|
#ifdef GRUB_MACHINE_PCBIOS
|
||||||
#include <grub/machine/biosnum.h>
|
#include <grub/machine/biosnum.h>
|
||||||
|
@ -205,28 +204,26 @@ grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry)
|
||||||
{
|
{
|
||||||
struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry;
|
struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
mmap_entry->addr = addr;
|
mmap_entry->addr = addr;
|
||||||
mmap_entry->len = size;
|
mmap_entry->len = size;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
case GRUB_MEMORY_AVAILABLE:
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE
|
case GRUB_MEMORY_ACPI:
|
||||||
case GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE:
|
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
case GRUB_MEMORY_NVS:
|
||||||
case GRUB_MACHINE_MEMORY_NVS:
|
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_NVS;
|
mmap_entry->type = MULTIBOOT_MEMORY_NVS;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <grub/loader.h>
|
#include <grub/loader.h>
|
||||||
#include <grub/machine/loader.h>
|
#include <grub/machine/loader.h>
|
||||||
#include <grub/machine/chainloader.h>
|
#include <grub/machine/chainloader.h>
|
||||||
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/device.h>
|
#include <grub/device.h>
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/cpu/linux.h>
|
#include <grub/cpu/linux.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/mips/relocator.h>
|
#include <grub/mips/relocator.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
/* For frequencies. */
|
/* For frequencies. */
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/multiboot.h>
|
#include <grub/multiboot.h>
|
||||||
#include <grub/cpu/multiboot.h>
|
#include <grub/cpu/multiboot.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/elf.h>
|
#include <grub/elf.h>
|
||||||
#include <grub/aout.h>
|
#include <grub/aout.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
|
@ -71,7 +70,7 @@ grub_get_multiboot_mmap_count (void)
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
#ifdef GRUB_MACHINE_PCBIOS
|
#ifdef GRUB_MACHINE_PCBIOS
|
||||||
#include <grub/machine/biosnum.h>
|
#include <grub/machine/biosnum.h>
|
||||||
#include <grub/machine/apm.h>
|
#include <grub/machine/apm.h>
|
||||||
|
#include <grub/machine/memory.h>
|
||||||
#endif
|
#endif
|
||||||
#include <grub/multiboot.h>
|
#include <grub/multiboot.h>
|
||||||
#include <grub/cpu/multiboot.h>
|
#include <grub/cpu/multiboot.h>
|
||||||
|
@ -290,28 +290,26 @@ grub_fill_multiboot_mmap (struct multiboot_tag_mmap *tag)
|
||||||
{
|
{
|
||||||
struct multiboot_mmap_entry *mmap_entry = tag->entries;
|
struct multiboot_mmap_entry *mmap_entry = tag->entries;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
grub_memory_type_t);
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
mmap_entry->addr = addr;
|
mmap_entry->addr = addr;
|
||||||
mmap_entry->len = size;
|
mmap_entry->len = size;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
case GRUB_MEMORY_AVAILABLE:
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE
|
case GRUB_MEMORY_ACPI:
|
||||||
case GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE:
|
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
case GRUB_MEMORY_NVS:
|
||||||
case GRUB_MACHINE_MEMORY_NVS:
|
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_NVS;
|
mmap_entry->type = MULTIBOOT_MEMORY_NVS;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <grub/ieee1275/ieee1275.h>
|
#include <grub/ieee1275/ieee1275.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
|
|
||||||
static grub_dl_t my_mod;
|
static grub_dl_t my_mod;
|
||||||
|
|
||||||
|
@ -181,8 +182,10 @@ alloc_phys (grub_addr_t size)
|
||||||
{
|
{
|
||||||
grub_addr_t ret = (grub_addr_t) -1;
|
grub_addr_t ret = (grub_addr_t) -1;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR choose (grub_uint64_t addr, grub_uint64_t len __attribute__((unused)), grub_uint32_t type);
|
auto int NESTED_FUNC_ATTR choose (grub_uint64_t addr, grub_uint64_t len,
|
||||||
int NESTED_FUNC_ATTR choose (grub_uint64_t addr, grub_uint64_t len __attribute__((unused)), grub_uint32_t type)
|
grub_memory_type_t type);
|
||||||
|
int NESTED_FUNC_ATTR choose (grub_uint64_t addr, grub_uint64_t len,
|
||||||
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
grub_addr_t end = addr + len;
|
grub_addr_t end = addr + len;
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,7 @@
|
||||||
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
|
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
grub_uint64_t,
|
|
||||||
grub_uint32_t))
|
|
||||||
{
|
{
|
||||||
grub_efi_uintn_t mmap_size = 0;
|
grub_efi_uintn_t mmap_size = 0;
|
||||||
grub_efi_memory_descriptor_t *map_buf = 0;
|
grub_efi_memory_descriptor_t *map_buf = 0;
|
||||||
|
@ -69,7 +67,12 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
{
|
{
|
||||||
case GRUB_EFI_RUNTIME_SERVICES_CODE:
|
case GRUB_EFI_RUNTIME_SERVICES_CODE:
|
||||||
hook (desc->physical_start, desc->num_pages * 4096,
|
hook (desc->physical_start, desc->num_pages * 4096,
|
||||||
GRUB_MACHINE_MEMORY_CODE);
|
GRUB_MEMORY_CODE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GRUB_EFI_UNUSABLE_MEMORY:
|
||||||
|
hook (desc->physical_start, desc->num_pages * 4096,
|
||||||
|
GRUB_MEMORY_BADRAM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -78,12 +81,11 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
|
|
||||||
case GRUB_EFI_RESERVED_MEMORY_TYPE:
|
case GRUB_EFI_RESERVED_MEMORY_TYPE:
|
||||||
case GRUB_EFI_RUNTIME_SERVICES_DATA:
|
case GRUB_EFI_RUNTIME_SERVICES_DATA:
|
||||||
case GRUB_EFI_UNUSABLE_MEMORY:
|
|
||||||
case GRUB_EFI_MEMORY_MAPPED_IO:
|
case GRUB_EFI_MEMORY_MAPPED_IO:
|
||||||
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
||||||
case GRUB_EFI_PAL_CODE:
|
case GRUB_EFI_PAL_CODE:
|
||||||
hook (desc->physical_start, desc->num_pages * 4096,
|
hook (desc->physical_start, desc->num_pages * 4096,
|
||||||
GRUB_MACHINE_MEMORY_RESERVED);
|
GRUB_MEMORY_RESERVED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_LOADER_CODE:
|
case GRUB_EFI_LOADER_CODE:
|
||||||
|
@ -92,17 +94,17 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
case GRUB_EFI_BOOT_SERVICES_DATA:
|
case GRUB_EFI_BOOT_SERVICES_DATA:
|
||||||
case GRUB_EFI_CONVENTIONAL_MEMORY:
|
case GRUB_EFI_CONVENTIONAL_MEMORY:
|
||||||
hook (desc->physical_start, desc->num_pages * 4096,
|
hook (desc->physical_start, desc->num_pages * 4096,
|
||||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
GRUB_MEMORY_AVAILABLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
|
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
|
||||||
hook (desc->physical_start, desc->num_pages * 4096,
|
hook (desc->physical_start, desc->num_pages * 4096,
|
||||||
GRUB_MACHINE_MEMORY_ACPI);
|
GRUB_MEMORY_ACPI);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRUB_EFI_ACPI_MEMORY_NVS:
|
case GRUB_EFI_ACPI_MEMORY_NVS:
|
||||||
hook (desc->physical_start, desc->num_pages * 4096,
|
hook (desc->physical_start, desc->num_pages * 4096,
|
||||||
GRUB_MACHINE_MEMORY_NVS);
|
GRUB_MEMORY_NVS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,29 +117,26 @@ make_efi_memtype (int type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GRUB_MACHINE_MEMORY_CODE:
|
case GRUB_MEMORY_CODE:
|
||||||
return GRUB_EFI_RUNTIME_SERVICES_CODE;
|
return GRUB_EFI_RUNTIME_SERVICES_CODE;
|
||||||
|
|
||||||
/* No way to remove a chunk of memory from EFI mmap.
|
/* No way to remove a chunk of memory from EFI mmap.
|
||||||
So mark it as unusable. */
|
So mark it as unusable. */
|
||||||
case GRUB_MACHINE_MEMORY_HOLE:
|
case GRUB_MEMORY_HOLE:
|
||||||
|
case GRUB_MEMORY_RESERVED:
|
||||||
default:
|
|
||||||
|
|
||||||
case GRUB_MACHINE_MEMORY_RESERVED:
|
|
||||||
return GRUB_EFI_UNUSABLE_MEMORY;
|
return GRUB_EFI_UNUSABLE_MEMORY;
|
||||||
|
|
||||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
case GRUB_MEMORY_AVAILABLE:
|
||||||
return GRUB_EFI_CONVENTIONAL_MEMORY;
|
return GRUB_EFI_CONVENTIONAL_MEMORY;
|
||||||
|
|
||||||
case GRUB_MACHINE_MEMORY_ACPI:
|
case GRUB_MEMORY_ACPI:
|
||||||
return GRUB_EFI_ACPI_RECLAIM_MEMORY;
|
|
||||||
|
|
||||||
case GRUB_MACHINE_MEMORY_NVS:
|
|
||||||
return GRUB_EFI_ACPI_RECLAIM_MEMORY;
|
return GRUB_EFI_ACPI_RECLAIM_MEMORY;
|
||||||
|
|
||||||
|
case GRUB_MEMORY_NVS:
|
||||||
|
return GRUB_EFI_ACPI_MEMORY_NVS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return GRUB_EFI_UNUSABLE_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct overlay
|
struct overlay
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
|
#include <grub/i386/memory.h>
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
@ -33,12 +34,12 @@ grub_mmap_malign_and_register (grub_uint64_t align, grub_uint64_t size,
|
||||||
grub_uint64_t highestlow = 0;
|
grub_uint64_t highestlow = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
||||||
grub_uint32_t);
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR find_hook (grub_uint64_t start, grub_uint64_t rangesize,
|
int NESTED_FUNC_ATTR find_hook (grub_uint64_t start, grub_uint64_t rangesize,
|
||||||
grub_uint32_t memtype)
|
grub_memory_type_t memtype)
|
||||||
{
|
{
|
||||||
grub_uint64_t end = start + rangesize;
|
grub_uint64_t end = start + rangesize;
|
||||||
if (memtype != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (memtype != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (end > 0x100000)
|
if (end > 0x100000)
|
||||||
end = 0x100000;
|
end = 0x100000;
|
||||||
|
|
|
@ -57,7 +57,7 @@ preboot (int noreturn __attribute__ ((unused)))
|
||||||
auto int NESTED_FUNC_ATTR fill_hook (grub_uint64_t, grub_uint64_t,
|
auto int NESTED_FUNC_ATTR fill_hook (grub_uint64_t, grub_uint64_t,
|
||||||
grub_uint32_t);
|
grub_uint32_t);
|
||||||
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
grub_dprintf ("mmap", "mmap chunk %llx-%llx:%x\n", addr, addr + size, type);
|
grub_dprintf ("mmap", "mmap chunk %llx-%llx:%x\n", addr, addr + size, type);
|
||||||
hookmmapcur->addr = addr;
|
hookmmapcur->addr = addr;
|
||||||
|
@ -135,7 +135,7 @@ malloc_hook (void)
|
||||||
grub_uint32_t);
|
grub_uint32_t);
|
||||||
int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
regcount++;
|
regcount++;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -172,7 +172,7 @@ malloc_hook (void)
|
||||||
reentry = 1;
|
reentry = 1;
|
||||||
hooktarget
|
hooktarget
|
||||||
= grub_mmap_malign_and_register (16, hooksize, &mmapregion,
|
= grub_mmap_malign_and_register (16, hooksize, &mmapregion,
|
||||||
GRUB_MACHINE_MEMORY_RESERVED,
|
GRUB_MEMORY_RESERVED,
|
||||||
GRUB_MMAP_MALLOC_LOW);
|
GRUB_MMAP_MALLOC_LOW);
|
||||||
reentry = 0;
|
reentry = 0;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
|
#include <grub/i386/memory.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
|
||||||
|
@ -26,11 +27,12 @@ grub_mmap_get_lower (void)
|
||||||
{
|
{
|
||||||
grub_uint64_t lower = 0;
|
grub_uint64_t lower = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (addr == 0)
|
if (addr == 0)
|
||||||
lower = size;
|
lower = size;
|
||||||
|
@ -48,11 +50,12 @@ grub_mmap_get_upper (void)
|
||||||
{
|
{
|
||||||
grub_uint64_t upper = 0;
|
grub_uint64_t upper = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (addr <= 0x100000 && addr + size > 0x100000)
|
if (addr <= 0x100000 && addr + size > 0x100000)
|
||||||
upper = addr + size - 0x100000;
|
upper = addr + size - 0x100000;
|
||||||
|
@ -69,11 +72,12 @@ grub_mmap_get_post64 (void)
|
||||||
{
|
{
|
||||||
grub_uint64_t post64 = 0;
|
grub_uint64_t post64 = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (addr <= 0x4000000 && addr + size > 0x4000000)
|
if (addr <= 0x4000000 && addr + size > 0x4000000)
|
||||||
post64 = addr + size - 0x4000000;
|
post64 = addr + size - 0x4000000;
|
||||||
|
|
|
@ -27,11 +27,12 @@ grub_mmap_get_lower (void)
|
||||||
{
|
{
|
||||||
grub_uint64_t lower = 0;
|
grub_uint64_t lower = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (addr == 0)
|
if (addr == 0)
|
||||||
lower = size;
|
lower = size;
|
||||||
|
@ -49,11 +50,12 @@ grub_mmap_get_upper (void)
|
||||||
{
|
{
|
||||||
grub_uint64_t upper = 0;
|
grub_uint64_t upper = 0;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
if (type != GRUB_MEMORY_AVAILABLE)
|
||||||
return 0;
|
return 0;
|
||||||
if (addr <= GRUB_ARCH_HIGHMEMPSTART && addr + size
|
if (addr <= GRUB_ARCH_HIGHMEMPSTART && addr + size
|
||||||
> GRUB_ARCH_HIGHMEMPSTART)
|
> GRUB_ARCH_HIGHMEMPSTART)
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
|
@ -34,8 +34,7 @@ static int curhandle = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
grub_mmap_iterate (grub_memory_hook_t hook)
|
||||||
grub_uint64_t, grub_uint32_t))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/* This function resolves overlapping regions and sorts the memory map.
|
/* This function resolves overlapping regions and sorts the memory map.
|
||||||
|
@ -48,27 +47,17 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
3 - unusable memory
|
3 - unusable memory
|
||||||
4 - a range deliberately empty
|
4 - a range deliberately empty
|
||||||
*/
|
*/
|
||||||
int priority[GRUB_MACHINE_MEMORY_MAX_TYPE + 2] =
|
int priority[] =
|
||||||
{
|
{
|
||||||
#ifdef GRUB_MACHINE_MEMORY_AVAILABLE
|
[GRUB_MEMORY_AVAILABLE] = 1,
|
||||||
[GRUB_MACHINE_MEMORY_AVAILABLE] = 1,
|
[GRUB_MEMORY_RESERVED] = 3,
|
||||||
#endif
|
[GRUB_MEMORY_ACPI] = 2,
|
||||||
#if defined (GRUB_MACHINE_MEMORY_RESERVED) && GRUB_MACHINE_MEMORY_RESERVED != GRUB_MACHINE_MEMORY_HOLE
|
[GRUB_MEMORY_CODE] = 3,
|
||||||
[GRUB_MACHINE_MEMORY_RESERVED] = 3,
|
[GRUB_MEMORY_NVS] = 3,
|
||||||
#endif
|
[GRUB_MEMORY_HOLE] = 4,
|
||||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
|
||||||
[GRUB_MACHINE_MEMORY_ACPI] = 2,
|
|
||||||
#endif
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_CODE
|
|
||||||
[GRUB_MACHINE_MEMORY_CODE] = 3,
|
|
||||||
#endif
|
|
||||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
|
||||||
[GRUB_MACHINE_MEMORY_NVS] = 3,
|
|
||||||
#endif
|
|
||||||
[GRUB_MACHINE_MEMORY_HOLE] = 4,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int i, k, done;
|
int i, done;
|
||||||
|
|
||||||
/* Scanline events. */
|
/* Scanline events. */
|
||||||
struct grub_mmap_scan
|
struct grub_mmap_scan
|
||||||
|
@ -89,7 +78,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
/* Current scanline event. */
|
/* Current scanline event. */
|
||||||
int curtype;
|
int curtype;
|
||||||
/* How many regions of given type overlap at current location? */
|
/* How many regions of given type overlap at current location? */
|
||||||
int present[GRUB_MACHINE_MEMORY_MAX_TYPE + 2];
|
int present[ARRAY_SIZE (priority)];
|
||||||
/* Number of mmap chunks. */
|
/* Number of mmap chunks. */
|
||||||
int mmap_num;
|
int mmap_num;
|
||||||
|
|
||||||
|
@ -101,7 +90,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
grub_uint32_t);
|
grub_uint32_t);
|
||||||
int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
mmap_num++;
|
mmap_num++;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -111,17 +100,17 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
grub_uint32_t);
|
grub_uint32_t);
|
||||||
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr,
|
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr,
|
||||||
grub_uint64_t size,
|
grub_uint64_t size,
|
||||||
grub_uint32_t type)
|
grub_memory_type_t type)
|
||||||
{
|
{
|
||||||
scanline_events[i].pos = addr;
|
scanline_events[i].pos = addr;
|
||||||
scanline_events[i].type = 0;
|
scanline_events[i].type = 0;
|
||||||
if (type <= GRUB_MACHINE_MEMORY_MAX_TYPE && priority[type])
|
if (type < ARRAY_SIZE (priority) && priority[type])
|
||||||
scanline_events[i].memtype = type;
|
scanline_events[i].memtype = type;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grub_dprintf ("mmap", "Unknown memory type %d. Assuming unusable\n",
|
grub_dprintf ("mmap", "Unknown memory type %d. Assuming unusable\n",
|
||||||
type);
|
type);
|
||||||
scanline_events[i].memtype = GRUB_MACHINE_MEMORY_RESERVED;
|
scanline_events[i].memtype = GRUB_MEMORY_RESERVED;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
@ -160,12 +149,10 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
{
|
{
|
||||||
scanline_events[i].pos = cur->start;
|
scanline_events[i].pos = cur->start;
|
||||||
scanline_events[i].type = 0;
|
scanline_events[i].type = 0;
|
||||||
if (cur->type == GRUB_MACHINE_MEMORY_HOLE
|
if (cur->type < ARRAY_SIZE (priority) && priority[cur->type])
|
||||||
|| (cur->type >= 0 && cur->type <= GRUB_MACHINE_MEMORY_MAX_TYPE
|
|
||||||
&& priority[cur->type]))
|
|
||||||
scanline_events[i].memtype = cur->type;
|
scanline_events[i].memtype = cur->type;
|
||||||
else
|
else
|
||||||
scanline_events[i].memtype = GRUB_MACHINE_MEMORY_RESERVED;
|
scanline_events[i].memtype = GRUB_MEMORY_RESERVED;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
scanline_events[i].pos = cur->end;
|
scanline_events[i].pos = cur->end;
|
||||||
|
@ -201,6 +188,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
lasttype = scanline_events[0].memtype;
|
lasttype = scanline_events[0].memtype;
|
||||||
for (i = 0; i < 2 * mmap_num; i++)
|
for (i = 0; i < 2 * mmap_num; i++)
|
||||||
{
|
{
|
||||||
|
unsigned k;
|
||||||
/* Process event. */
|
/* Process event. */
|
||||||
if (scanline_events[i].type)
|
if (scanline_events[i].type)
|
||||||
present[scanline_events[i].memtype]--;
|
present[scanline_events[i].memtype]--;
|
||||||
|
@ -209,7 +197,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
|
|
||||||
/* Determine current region type. */
|
/* Determine current region type. */
|
||||||
curtype = -1;
|
curtype = -1;
|
||||||
for (k = 0; k <= GRUB_MACHINE_MEMORY_MAX_TYPE + 1; k++)
|
for (k = 0; k < ARRAY_SIZE (priority); k++)
|
||||||
if (present[k] && (curtype == -1 || priority[k] > priority[curtype]))
|
if (present[k] && (curtype == -1 || priority[k] > priority[curtype]))
|
||||||
curtype = k;
|
curtype = k;
|
||||||
|
|
||||||
|
@ -217,7 +205,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
if ((curtype == -1 || curtype != lasttype)
|
if ((curtype == -1 || curtype != lasttype)
|
||||||
&& lastaddr != scanline_events[i].pos
|
&& lastaddr != scanline_events[i].pos
|
||||||
&& lasttype != -1
|
&& lasttype != -1
|
||||||
&& lasttype != GRUB_MACHINE_MEMORY_HOLE
|
&& lasttype != GRUB_MEMORY_HOLE
|
||||||
&& hook (lastaddr, scanline_events[i].pos - lastaddr, lasttype))
|
&& hook (lastaddr, scanline_events[i].pos - lastaddr, lasttype))
|
||||||
{
|
{
|
||||||
grub_free (scanline_events);
|
grub_free (scanline_events);
|
||||||
|
@ -324,10 +312,11 @@ grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)),
|
||||||
char * str;
|
char * str;
|
||||||
grub_uint64_t badaddr, badmask;
|
grub_uint64_t badaddr, badmask;
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
||||||
|
grub_memory_type_t);
|
||||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr,
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr,
|
||||||
grub_uint64_t size,
|
grub_uint64_t size,
|
||||||
grub_uint32_t type __attribute__ ((unused)))
|
grub_memory_type_t type __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_uint64_t iterator, low, high, cur;
|
grub_uint64_t iterator, low, high, cur;
|
||||||
int tail, var;
|
int tail, var;
|
||||||
|
@ -370,7 +359,7 @@ grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
grub_dprintf ("badram", "%llx (size %llx) is a badram range\n",
|
grub_dprintf ("badram", "%llx (size %llx) is a badram range\n",
|
||||||
(unsigned long long) cur, (1ULL << tail));
|
(unsigned long long) cur, (1ULL << tail));
|
||||||
grub_mmap_register (cur, (1ULL << tail), GRUB_MACHINE_MEMORY_HOLE);
|
grub_mmap_register (cur, (1ULL << tail), GRUB_MEMORY_HOLE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
#include <grub/serial.h>
|
#include <grub/serial.h>
|
||||||
#include <grub/ns8250.h>
|
#include <grub/ns8250.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_PCBIOS
|
#ifdef GRUB_MACHINE_PCBIOS
|
||||||
|
#include <grub/machine/memory.h>
|
||||||
static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
|
static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
|
||||||
#define GRUB_SERIAL_PORT_NUM 4
|
#define GRUB_SERIAL_PORT_NUM 4
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -34,17 +34,6 @@ static inline grub_err_t grub_autoefi_prepare (void)
|
||||||
{
|
{
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
};
|
};
|
||||||
# define GRUB_AUTOEFI_MEMORY_AVAILABLE GRUB_MACHINE_MEMORY_AVAILABLE
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_RESERVED GRUB_MACHINE_MEMORY_RESERVED
|
|
||||||
# ifdef GRUB_MACHINE_MEMORY_ACPI
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_ACPI GRUB_MACHINE_MEMORY_ACPI
|
|
||||||
# endif
|
|
||||||
# ifdef GRUB_MACHINE_MEMORY_NVS
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_NVS GRUB_MACHINE_MEMORY_NVS
|
|
||||||
# endif
|
|
||||||
# ifdef GRUB_MACHINE_MEMORY_CODE
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_CODE GRUB_MACHINE_MEMORY_CODE
|
|
||||||
# endif
|
|
||||||
# define SYSTEM_TABLE_SIZEOF(x) (sizeof(grub_efi_system_table->x))
|
# define SYSTEM_TABLE_SIZEOF(x) (sizeof(grub_efi_system_table->x))
|
||||||
# define SYSTEM_TABLE_VAR(x) ((void *)&(grub_efi_system_table->x))
|
# define SYSTEM_TABLE_VAR(x) ((void *)&(grub_efi_system_table->x))
|
||||||
# define SYSTEM_TABLE_PTR(x) ((void *)(grub_efi_system_table->x))
|
# define SYSTEM_TABLE_PTR(x) ((void *)(grub_efi_system_table->x))
|
||||||
|
@ -61,11 +50,6 @@ static inline grub_err_t grub_autoefi_prepare (void)
|
||||||
# define grub_autoefi_mmap_iterate grub_efiemu_mmap_iterate
|
# define grub_autoefi_mmap_iterate grub_efiemu_mmap_iterate
|
||||||
# define grub_autoefi_prepare grub_efiemu_prepare
|
# define grub_autoefi_prepare grub_efiemu_prepare
|
||||||
# define grub_autoefi_set_virtual_address_map grub_efiemu_set_virtual_address_map
|
# define grub_autoefi_set_virtual_address_map grub_efiemu_set_virtual_address_map
|
||||||
# define GRUB_AUTOEFI_MEMORY_AVAILABLE GRUB_EFIEMU_MEMORY_AVAILABLE
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_RESERVED GRUB_EFIEMU_MEMORY_RESERVED
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_ACPI GRUB_EFIEMU_MEMORY_ACPI
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_NVS GRUB_EFIEMU_MEMORY_NVS
|
|
||||||
# define GRUB_AUTOEFI_MEMORY_CODE GRUB_EFIEMU_MEMORY_CODE
|
|
||||||
# define SYSTEM_TABLE_SIZEOF GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF
|
# define SYSTEM_TABLE_SIZEOF GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF
|
||||||
# define SYSTEM_TABLE_VAR GRUB_EFIEMU_SYSTEM_TABLE_VAR
|
# define SYSTEM_TABLE_VAR GRUB_EFIEMU_SYSTEM_TABLE_VAR
|
||||||
# define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR
|
# define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR
|
||||||
|
|
|
@ -24,16 +24,6 @@
|
||||||
|
|
||||||
#define GRUB_MMAP_REGISTER_BY_FIRMWARE 1
|
#define GRUB_MMAP_REGISTER_BY_FIRMWARE 1
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
#define GRUB_MACHINE_MEMORY_RESERVED 2
|
|
||||||
#define GRUB_MACHINE_MEMORY_ACPI 3
|
|
||||||
#define GRUB_MACHINE_MEMORY_NVS 4
|
|
||||||
#define GRUB_MACHINE_MEMORY_CODE 5
|
|
||||||
#define GRUB_MACHINE_MEMORY_MAX_TYPE 5
|
|
||||||
/* This one is special: it's used internally but is never reported
|
|
||||||
by firmware. */
|
|
||||||
#define GRUB_MACHINE_MEMORY_HOLE 6
|
|
||||||
|
|
||||||
grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
grub_uint64_t,
|
grub_uint64_t,
|
||||||
grub_uint32_t));
|
grub_uint32_t));
|
||||||
|
|
|
@ -233,11 +233,6 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
int grub_efiemu_sizeof_uintn_t (void);
|
int grub_efiemu_sizeof_uintn_t (void);
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_efiemu_get_lower_upper_memory (grub_uint64_t *lower, grub_uint64_t *upper);
|
grub_efiemu_get_lower_upper_memory (grub_uint64_t *lower, grub_uint64_t *upper);
|
||||||
#define GRUB_EFIEMU_MEMORY_AVAILABLE 1
|
|
||||||
#define GRUB_EFIEMU_MEMORY_RESERVED 2
|
|
||||||
#define GRUB_EFIEMU_MEMORY_ACPI 3
|
|
||||||
#define GRUB_EFIEMU_MEMORY_NVS 4
|
|
||||||
#define GRUB_EFIEMU_MEMORY_CODE 5
|
|
||||||
|
|
||||||
/* efiemu main control definitions and functions*/
|
/* efiemu main control definitions and functions*/
|
||||||
typedef enum {GRUB_EFIEMU_NOTLOADED,
|
typedef enum {GRUB_EFIEMU_NOTLOADED,
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
#define _GRUB_MEMORY_MACHINE_LB_HEADER 1
|
#define _GRUB_MEMORY_MACHINE_LB_HEADER 1
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/i386/pc/memory.h>
|
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */
|
#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */
|
||||||
|
@ -35,36 +35,21 @@
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
struct grub_linuxbios_table_header
|
|
||||||
{
|
|
||||||
char signature[4];
|
|
||||||
grub_uint32_t size;
|
|
||||||
};
|
|
||||||
typedef struct grub_linuxbios_table_header *grub_linuxbios_table_header_t;
|
|
||||||
|
|
||||||
struct grub_linuxbios_table_item
|
|
||||||
{
|
|
||||||
#define GRUB_LINUXBIOS_MEMBER_UNUSED 0x00
|
|
||||||
#define GRUB_LINUXBIOS_MEMBER_MEMORY 0x01
|
|
||||||
#define GRUB_LINUXBIOS_MEMBER_LINK 0x11
|
|
||||||
grub_uint32_t tag;
|
|
||||||
grub_uint32_t size;
|
|
||||||
};
|
|
||||||
typedef struct grub_linuxbios_table_item *grub_linuxbios_table_item_t;
|
|
||||||
|
|
||||||
struct grub_linuxbios_mem_region
|
|
||||||
{
|
|
||||||
grub_uint64_t addr;
|
|
||||||
grub_uint64_t size;
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
grub_uint32_t type;
|
|
||||||
};
|
|
||||||
typedef struct grub_linuxbios_mem_region *mem_region_t;
|
|
||||||
|
|
||||||
void grub_machine_mmap_init (void);
|
void grub_machine_mmap_init (void);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
|
static inline grub_err_t
|
||||||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
|
||||||
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
|
int type __attribute__ ((unused)),
|
||||||
|
int handle __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
static inline grub_err_t
|
||||||
|
grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#include <grub/i386/pc/memory.h>
|
#include <grub/i386/coreboot/memory.h>
|
||||||
|
|
|
@ -30,6 +30,14 @@
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
#define GRUB_MMAP_MALLOC_LOW 1
|
||||||
|
|
||||||
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
grub_uint64_t grub_mmap_get_upper (void);
|
||||||
|
grub_uint64_t grub_mmap_get_lower (void);
|
||||||
|
grub_uint64_t grub_mmap_get_post64 (void);
|
||||||
|
|
||||||
typedef grub_addr_t grub_phys_addr_t;
|
typedef grub_addr_t grub_phys_addr_t;
|
||||||
|
|
||||||
static inline grub_phys_addr_t
|
static inline grub_phys_addr_t
|
||||||
|
|
|
@ -88,51 +88,9 @@ struct grub_machine_bios_data_area
|
||||||
grub_uint8_t unused2[0xf0 - 0x18];
|
grub_uint8_t unused2[0xf0 - 0x18];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct grub_machine_mmap_entry
|
|
||||||
{
|
|
||||||
grub_uint32_t size;
|
|
||||||
grub_uint64_t addr;
|
|
||||||
grub_uint64_t len;
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
#define GRUB_MACHINE_MEMORY_RESERVED 2
|
|
||||||
#define GRUB_MACHINE_MEMORY_ACPI 3
|
|
||||||
#define GRUB_MACHINE_MEMORY_NVS 4
|
|
||||||
#define GRUB_MACHINE_MEMORY_MAX_TYPE 4
|
|
||||||
/* This one is special: it's used internally but is never reported
|
|
||||||
by firmware. */
|
|
||||||
#define GRUB_MACHINE_MEMORY_HOLE 5
|
|
||||||
|
|
||||||
grub_uint32_t type;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
|
|
||||||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
|
||||||
|
|
||||||
grub_uint64_t grub_mmap_get_post64 (void);
|
|
||||||
grub_uint64_t grub_mmap_get_upper (void);
|
|
||||||
grub_uint64_t grub_mmap_get_lower (void);
|
|
||||||
|
|
||||||
#define GRUB_MMAP_MALLOC_LOW 1
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_PCBIOS
|
|
||||||
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
|
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
|
||||||
int type, int handle);
|
int type, int handle);
|
||||||
grub_err_t grub_machine_mmap_unregister (int handle);
|
grub_err_t grub_machine_mmap_unregister (int handle);
|
||||||
#else
|
|
||||||
static inline grub_err_t
|
|
||||||
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
|
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
|
||||||
int type __attribute__ ((unused)),
|
|
||||||
int handle __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
static inline grub_err_t
|
|
||||||
grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#define _GRUB_MEMORY_MACHINE_HEADER 1
|
#define _GRUB_MEMORY_MACHINE_HEADER 1
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/i386/pc/memory.h>
|
#include <grub/i386/coreboot/memory.h>
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
|
@ -37,9 +37,6 @@
|
||||||
|
|
||||||
void grub_machine_mmap_init (void);
|
void grub_machine_mmap_init (void);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
|
|
||||||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ! _GRUB_MEMORY_MACHINE_HEADER */
|
#endif /* ! _GRUB_MEMORY_MACHINE_HEADER */
|
||||||
|
|
|
@ -22,11 +22,32 @@
|
||||||
|
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
|
|
||||||
grub_err_t grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
typedef enum grub_memory_type
|
||||||
|
{
|
||||||
|
GRUB_MEMORY_AVAILABLE = 1,
|
||||||
|
GRUB_MEMORY_RESERVED = 2,
|
||||||
|
GRUB_MEMORY_ACPI = 3,
|
||||||
|
GRUB_MEMORY_NVS = 4,
|
||||||
|
GRUB_MEMORY_BADRAM = 5,
|
||||||
|
GRUB_MEMORY_CODE = 20,
|
||||||
|
/* This one is special: it's used internally but is never reported
|
||||||
|
by firmware. */
|
||||||
|
GRUB_MEMORY_HOLE = 21
|
||||||
|
} grub_memory_type_t;
|
||||||
|
|
||||||
|
typedef int NESTED_FUNC_ATTR (*grub_memory_hook_t) (grub_uint64_t,
|
||||||
grub_uint64_t,
|
grub_uint64_t,
|
||||||
grub_uint32_t));
|
grub_memory_type_t);
|
||||||
|
|
||||||
|
grub_err_t grub_mmap_iterate (grub_memory_hook_t hook);
|
||||||
|
|
||||||
|
#if !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_EFI)
|
||||||
|
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) (grub_memory_hook_t hook);
|
||||||
|
#else
|
||||||
|
grub_err_t grub_machine_mmap_iterate (grub_memory_hook_t hook);
|
||||||
|
#endif
|
||||||
|
|
||||||
int grub_mmap_register (grub_uint64_t start, grub_uint64_t size, int type);
|
int grub_mmap_register (grub_uint64_t start, grub_uint64_t size, int type);
|
||||||
grub_err_t grub_mmap_unregister (int handle);
|
grub_err_t grub_mmap_unregister (int handle);
|
||||||
|
|
||||||
|
@ -42,7 +63,7 @@ struct grub_mmap_region
|
||||||
struct grub_mmap_region *next;
|
struct grub_mmap_region *next;
|
||||||
grub_uint64_t start;
|
grub_uint64_t start;
|
||||||
grub_uint64_t end;
|
grub_uint64_t end;
|
||||||
int type;
|
grub_memory_type_t type;
|
||||||
int handle;
|
int handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x80f00000
|
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x80f00000
|
||||||
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
|
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate)
|
grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate)
|
||||||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
||||||
|
|
|
@ -31,13 +31,6 @@
|
||||||
#define GRUB_ARCH_LOWMEMMAXSIZE 0x10000000
|
#define GRUB_ARCH_LOWMEMMAXSIZE 0x10000000
|
||||||
#define GRUB_ARCH_HIGHMEMPSTART 0x10000000
|
#define GRUB_ARCH_HIGHMEMPSTART 0x10000000
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
#define GRUB_MACHINE_MEMORY_MAX_TYPE 1
|
|
||||||
/* This one is special: it's used internally but is never reported
|
|
||||||
by firmware. */
|
|
||||||
#define GRUB_MACHINE_MEMORY_HOLE 2
|
|
||||||
#define GRUB_MACHINE_MEMORY_RESERVED GRUB_MACHINE_MEMORY_HOLE
|
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
typedef grub_addr_t grub_phys_addr_t;
|
typedef grub_addr_t grub_phys_addr_t;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* GRUB is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GRUB_MEMORY_MACHINE_HEADER
|
|
||||||
#define GRUB_MEMORY_MACHINE_HEADER 1
|
|
||||||
|
|
||||||
#include <grub/ieee1275/ieee1275.h>
|
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* GRUB is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GRUB_MEMORY_MACHINE_HEADER
|
|
||||||
#define GRUB_MEMORY_MACHINE_HEADER 1
|
|
||||||
|
|
||||||
#include <grub/ieee1275/ieee1275.h>
|
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Add table
Reference in a new issue