Reorganise memory map handling
This commit is contained in:
parent
dda060dd0f
commit
df3df23d5c
51 changed files with 301 additions and 443 deletions
|
@ -74,9 +74,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
|
|||
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/boot.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
|
||||
|
||||
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/kernel.h
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
|
||||
|
@ -92,24 +92,20 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
|||
endif
|
||||
|
||||
if COND_i386_coreboot
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||
endif
|
||||
|
||||
if COND_i386_multiboot
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||
endif
|
||||
|
||||
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/i386/pit.h
|
||||
endif
|
||||
|
||||
if COND_i386_ieee1275
|
||||
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/i386/pit.h
|
||||
endif
|
||||
|
@ -123,7 +119,6 @@ endif
|
|||
|
||||
if COND_mips_yeeloong
|
||||
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_srcdir)/include/grub/bitmap.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
|
||||
|
@ -135,7 +130,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
|||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.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/serial.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
|
||||
endif
|
||||
|
||||
if COND_powerpc_ieee1275
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/boot.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <grub/gzio.h>
|
||||
#include <grub/acpi.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
|
@ -152,10 +151,10 @@ grub_acpi_create_ebda (void)
|
|||
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
||||
grub_uint32_t);
|
||||
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;
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (end > 0x100000)
|
||||
end = 0x100000;
|
||||
|
@ -181,7 +180,7 @@ grub_acpi_create_ebda (void)
|
|||
"couldn't find space for the new EBDA");
|
||||
|
||||
mmapregion = grub_mmap_register (PTR_TO_UINT64 (targetebda), ebda_len,
|
||||
GRUB_MACHINE_MEMORY_RESERVED);
|
||||
GRUB_MEMORY_RESERVED);
|
||||
if (! mmapregion)
|
||||
return grub_errno;
|
||||
|
||||
|
@ -706,7 +705,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
|
||||
playground = playground_ptr
|
||||
= grub_mmap_malign_and_register (1, playground_size, &mmapregion,
|
||||
GRUB_MACHINE_MEMORY_ACPI, 0);
|
||||
GRUB_MEMORY_ACPI, 0);
|
||||
|
||||
if (! playground)
|
||||
{
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
#include <grub/disk.h>
|
||||
#include <grub/loader.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/biosnum.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. */
|
||||
|
@ -306,7 +307,7 @@ install_int13_handler (int noret __attribute__ ((unused)))
|
|||
grub_dprintf ("drivemap", "Payload is %u bytes long\n", total_size);
|
||||
handler_base = grub_mmap_malign_and_register (16, total_size,
|
||||
&drivemap_mmap,
|
||||
GRUB_MACHINE_MEMORY_RESERVED,
|
||||
GRUB_MEMORY_RESERVED,
|
||||
GRUB_MMAP_MALLOC_LOW);
|
||||
if (! handler_base)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't reserve "
|
||||
|
|
|
@ -16,24 +16,39 @@
|
|||
* 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/misc.h>
|
||||
#include <grub/command.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
|
||||
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);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
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_memory_type_t type)
|
||||
{
|
||||
grub_printf ("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n",
|
||||
(long long) addr, (long long) size, 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",
|
||||
(long long) addr, (long long) size, type);
|
||||
return 0;
|
||||
}
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
*/
|
||||
|
||||
#include <grub/machine/biosdisk.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/int.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include <grub/normal.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/efiemu/efiemu.h>
|
||||
#include <grub/memory.h>
|
||||
|
||||
struct grub_efiemu_memrequest
|
||||
{
|
||||
|
@ -269,10 +269,11 @@ static grub_err_t
|
|||
grub_efiemu_mmap_init (void)
|
||||
{
|
||||
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)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
mmap_reserved_size++;
|
||||
return 0;
|
||||
|
@ -382,32 +383,29 @@ grub_efiemu_mm_init (void)
|
|||
static grub_err_t
|
||||
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,
|
||||
grub_uint64_t size,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
return grub_efiemu_add_to_mmap (addr, size,
|
||||
GRUB_EFI_CONVENTIONAL_MEMORY);
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
||||
case GRUB_MACHINE_MEMORY_ACPI:
|
||||
case GRUB_MEMORY_ACPI:
|
||||
return grub_efiemu_add_to_mmap (addr, size,
|
||||
GRUB_EFI_ACPI_RECLAIM_MEMORY);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
||||
case GRUB_MACHINE_MEMORY_NVS:
|
||||
case GRUB_MEMORY_NVS:
|
||||
return grub_efiemu_add_to_mmap (addr, size,
|
||||
GRUB_EFI_ACPI_MEMORY_NVS);
|
||||
#endif
|
||||
|
||||
default:
|
||||
grub_printf ("Unknown memory type %d. Marking as unusable\n", type);
|
||||
case GRUB_MACHINE_MEMORY_RESERVED:
|
||||
grub_printf ("Unknown memory type %d. Assuming unusable\n", type);
|
||||
case GRUB_MEMORY_RESERVED:
|
||||
return grub_efiemu_add_to_mmap (addr, size,
|
||||
GRUB_EFI_UNUSABLE_MEMORY);
|
||||
}
|
||||
|
@ -421,9 +419,7 @@ grub_efiemu_mmap_fill (void)
|
|||
}
|
||||
|
||||
grub_err_t
|
||||
grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||
grub_uint64_t,
|
||||
grub_uint32_t))
|
||||
grub_efiemu_mmap_iterate (grub_memory_hook_t hook)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@ -432,18 +428,22 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
{
|
||||
case GRUB_EFI_RUNTIME_SERVICES_CODE:
|
||||
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;
|
||||
|
||||
case GRUB_EFI_RESERVED_MEMORY_TYPE:
|
||||
case GRUB_EFI_RUNTIME_SERVICES_DATA:
|
||||
case GRUB_EFI_UNUSABLE_MEMORY:
|
||||
case GRUB_EFI_MEMORY_MAPPED_IO:
|
||||
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
||||
case GRUB_EFI_PAL_CODE:
|
||||
case GRUB_EFI_MAX_MEMORY_TYPE:
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_EFIEMU_MEMORY_RESERVED);
|
||||
GRUB_MEMORY_RESERVED);
|
||||
break;
|
||||
|
||||
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_CONVENTIONAL_MEMORY:
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_EFIEMU_MEMORY_AVAILABLE);
|
||||
GRUB_MEMORY_AVAILABLE);
|
||||
break;
|
||||
|
||||
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_EFIEMU_MEMORY_ACPI);
|
||||
GRUB_MEMORY_ACPI);
|
||||
break;
|
||||
|
||||
case GRUB_EFI_ACPI_MEMORY_NVS:
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_EFIEMU_MEMORY_NVS);
|
||||
GRUB_MEMORY_NVS);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <grub/machine/time.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
|
@ -64,8 +65,10 @@ grub_machine_init (void)
|
|||
/* Initialize the console as early as possible. */
|
||||
grub_vga_text_init ();
|
||||
|
||||
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t,
|
||||
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
|
||||
/* Restrict ourselves to 32-bit memory space. */
|
||||
|
@ -75,7 +78,7 @@ grub_machine_init (void)
|
|||
size = GRUB_ULONG_MAX - addr;
|
||||
#endif
|
||||
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
|
||||
/* Avoid the lower memory. */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/lbio.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
|
@ -74,7 +75,7 @@ signature_found:
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
/* For stack parameters. */
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/offsets.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <multiboot.h>
|
||||
#include <multiboot2.h>
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
grub_size_t grub_lower_mem, grub_upper_mem;
|
||||
|
||||
/* A pointer to the MBI in its initial location. */
|
||||
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);
|
||||
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_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;
|
||||
|
||||
|
|
|
@ -186,8 +186,10 @@ grub_machine_init (void)
|
|||
grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END);
|
||||
#endif
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
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_memory_type_t type)
|
||||
{
|
||||
/* Avoid the lower memory. */
|
||||
if (addr < 0x100000)
|
||||
|
@ -200,7 +202,7 @@ grub_machine_init (void)
|
|||
}
|
||||
|
||||
/* Ignore >4GB. */
|
||||
if (addr <= 0xFFFFFFFF && type == GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (addr <= 0xFFFFFFFF && type == GRUB_MEMORY_AVAILABLE)
|
||||
{
|
||||
grub_size_t len;
|
||||
|
||||
|
|
|
@ -23,6 +23,20 @@
|
|||
#include <grub/types.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.
|
||||
* BIOS call "INT 15H, AH=88H" to get extended memory size
|
||||
|
@ -110,7 +124,7 @@ grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
|
|||
}
|
||||
|
||||
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;
|
||||
struct grub_machine_mmap_entry *entry
|
||||
|
@ -125,9 +139,9 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
do
|
||||
{
|
||||
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. */
|
||||
entry->type))
|
||||
((entry->type <= GRUB_MACHINE_MEMORY_BADRAM) && (entry->type >= GRUB_MACHINE_MEMORY_AVAILABLE)) ? entry->type : GRUB_MEMORY_RESERVED))
|
||||
break;
|
||||
|
||||
if (! cont)
|
||||
|
@ -144,11 +158,12 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
|
||||
if (eisa_mmap)
|
||||
{
|
||||
if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10, GRUB_MACHINE_MEMORY_AVAILABLE) == 0)
|
||||
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10,
|
||||
GRUB_MEMORY_AVAILABLE) == 0)
|
||||
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE);
|
||||
}
|
||||
else
|
||||
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MEMORY_AVAILABLE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/i386/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/boot.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/cmos.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
#define QEMU_CMOS_MEMSIZE_HIGH 0x35
|
||||
#define QEMU_CMOS_MEMSIZE_LOW 0x34
|
||||
|
@ -60,38 +62,38 @@ grub_machine_mmap_init ()
|
|||
}
|
||||
|
||||
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,
|
||||
(grub_addr_t) _start,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
GRUB_MEMORY_AVAILABLE))
|
||||
return 1;
|
||||
|
||||
if (hook ((grub_addr_t) _end,
|
||||
0xa0000 - (grub_addr_t) _end,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
GRUB_MEMORY_AVAILABLE))
|
||||
return 1;
|
||||
|
||||
if (hook (GRUB_MEMORY_MACHINE_UPPER,
|
||||
0x100000 - GRUB_MEMORY_MACHINE_UPPER,
|
||||
GRUB_MACHINE_MEMORY_RESERVED))
|
||||
GRUB_MEMORY_RESERVED))
|
||||
return 1;
|
||||
|
||||
/* Everything else is free. */
|
||||
if (hook (0x100000,
|
||||
min (mem_size, (grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE) - 0x100000,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
GRUB_MEMORY_AVAILABLE))
|
||||
return 1;
|
||||
|
||||
/* 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). */
|
||||
if (hook ((grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE,
|
||||
GRUB_BOOT_MACHINE_SIZE,
|
||||
GRUB_MACHINE_MEMORY_RESERVED))
|
||||
GRUB_MEMORY_RESERVED))
|
||||
return 1;
|
||||
|
||||
if (above_4g != 0 && hook (0x100000000ULL, above_4g,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
GRUB_MEMORY_AVAILABLE))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <grub/ieee1275/ofdisk.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/memory.h>
|
||||
|
||||
/* The minimal heap size we can live with. */
|
||||
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
|
||||
|
@ -126,8 +127,10 @@ static void grub_claim_heap (void)
|
|||
{
|
||||
unsigned long total = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type);
|
||||
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,
|
||||
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)
|
||||
return 0;
|
||||
|
@ -189,31 +192,6 @@ static void grub_claim_heap (void)
|
|||
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);
|
||||
|
||||
void
|
||||
|
@ -225,9 +203,6 @@ grub_machine_init (void)
|
|||
grub_ieee1275_init ();
|
||||
|
||||
grub_console_init_early ();
|
||||
#ifdef __i386__
|
||||
grub_get_extended_memory ();
|
||||
#endif
|
||||
grub_claim_heap ();
|
||||
grub_console_init_lately ();
|
||||
grub_ofdisk_init ();
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
* 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/types.h>
|
||||
|
||||
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 memory;
|
||||
|
@ -66,7 +66,7 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
if (size_cells == 2)
|
||||
size = (size << 32) | available[i++];
|
||||
|
||||
if (hook (address, size, GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
if (hook (address, size, GRUB_MEMORY_AVAILABLE))
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,8 @@ grub_reboot (void)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
hook (0, RAMSIZE,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
hook (0, RAMSIZE, GRUB_MEMORY_AVAILABLE);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/mips/loongson.h>
|
||||
#include <grub/cs5536.h>
|
||||
#include <grub/term.h>
|
||||
|
@ -57,14 +58,12 @@ grub_get_rtc (void)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
hook (GRUB_ARCH_LOWMEMPSTART, grub_arch_memsize << 20,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
GRUB_MEMORY_AVAILABLE);
|
||||
hook (GRUB_ARCH_HIGHMEMPSTART, grub_arch_highmemsize << 20,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
GRUB_MEMORY_AVAILABLE);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ grub_relocator_firmware_get_max_events (void)
|
|||
int counter = 0;
|
||||
auto int NESTED_FUNC_ATTR count (grub_uint64_t addr __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)),
|
||||
grub_uint64_t len __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type __attribute__ ((unused)))
|
||||
{
|
||||
counter++;
|
||||
return 0;
|
||||
|
@ -47,11 +47,11 @@ grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events)
|
|||
{
|
||||
int counter = 0;
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
|
||||
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;
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t sz, grub_uint32_t type)
|
||||
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 sz,
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
grub_uint64_t candidate;
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
candidate = ALIGN_UP (addr, align);
|
||||
if (candidate < min_addr)
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include <grub/loader.h>
|
||||
#include <grub/i386/bsd.h>
|
||||
#include <grub/i386/cpuid.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/i386/memory.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
|
@ -262,37 +262,30 @@ generate_e820_mmap (grub_size_t *len, grub_size_t *cnt, void *buf)
|
|||
struct grub_e820_mmap *mmap = buf;
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
cur.addr = addr;
|
||||
cur.size = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
cur.type = GRUB_E820_RAM;
|
||||
break;
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
||||
case GRUB_MACHINE_MEMORY_ACPI:
|
||||
case GRUB_MEMORY_ACPI:
|
||||
cur.type = GRUB_E820_ACPI;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
||||
case GRUB_MACHINE_MEMORY_NVS:
|
||||
case GRUB_MEMORY_NVS:
|
||||
cur.type = GRUB_E820_NVS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
#ifdef GRUB_MACHINE_MEMORY_CODE
|
||||
case GRUB_MACHINE_MEMORY_CODE:
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_MEMORY_RESERVED
|
||||
case GRUB_MACHINE_MEMORY_RESERVED:
|
||||
#endif
|
||||
case GRUB_MEMORY_CODE:
|
||||
case GRUB_MEMORY_RESERVED:
|
||||
cur.type = GRUB_E820_RESERVED;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
#include <grub/loader.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/file.h>
|
||||
|
@ -312,10 +311,11 @@ find_mmap_size (void)
|
|||
{
|
||||
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)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type __attribute__ ((unused)))
|
||||
{
|
||||
count++;
|
||||
return 0;
|
||||
|
@ -379,12 +379,14 @@ allocate_pages (grub_size_t prot_size)
|
|||
/* FIXME: Should request low memory from the heap when this feature is
|
||||
implemented. */
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
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_memory_type_t type)
|
||||
{
|
||||
/* We must put real mode code in the traditional space. */
|
||||
|
||||
if (type == GRUB_MACHINE_MEMORY_AVAILABLE
|
||||
if (type == GRUB_MEMORY_AVAILABLE
|
||||
&& addr <= 0x90000)
|
||||
{
|
||||
if (addr < 0x10000)
|
||||
|
@ -559,36 +561,32 @@ grub_linux_boot (void)
|
|||
grub_dprintf ("linux", "code32_start = %x\n",
|
||||
(unsigned) params->code32_start);
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
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_memory_type_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
grub_e820_add_region (params->e820_map, &e820_num,
|
||||
addr, size, GRUB_E820_RAM);
|
||||
break;
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_ACPI
|
||||
case GRUB_MACHINE_MEMORY_ACPI:
|
||||
case GRUB_MEMORY_ACPI:
|
||||
grub_e820_add_region (params->e820_map, &e820_num,
|
||||
addr, size, GRUB_E820_ACPI);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
||||
case GRUB_MACHINE_MEMORY_NVS:
|
||||
case GRUB_MEMORY_NVS:
|
||||
grub_e820_add_region (params->e820_map, &e820_num,
|
||||
addr, size, GRUB_E820_NVS);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_CODE
|
||||
case GRUB_MACHINE_MEMORY_CODE:
|
||||
case GRUB_MEMORY_CODE:
|
||||
grub_e820_add_region (params->e820_map, &e820_num,
|
||||
addr, size, GRUB_E820_EXEC_CODE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
grub_e820_add_region (params->e820_map, &e820_num,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
|
@ -203,28 +202,26 @@ grub_fill_multiboot_mmap (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);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
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_memory_type_t type)
|
||||
{
|
||||
mmap_entry->addr = addr;
|
||||
mmap_entry->len = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
break;
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE
|
||||
case GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE:
|
||||
case GRUB_MEMORY_ACPI:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
||||
case GRUB_MACHINE_MEMORY_NVS:
|
||||
case GRUB_MEMORY_NVS:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_NVS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/command.h>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/mips/relocator.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
/* For frequencies. */
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/multiboot.h>
|
||||
#include <grub/cpu/multiboot.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/aout.h>
|
||||
#include <grub/file.h>
|
||||
|
@ -74,7 +73,7 @@ grub_get_multiboot_mmap_count (void)
|
|||
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)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type __attribute__ ((unused)))
|
||||
{
|
||||
count++;
|
||||
return 0;
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#endif
|
||||
#include <grub/multiboot.h>
|
||||
#include <grub/cpu/multiboot.h>
|
||||
|
@ -288,28 +288,26 @@ grub_fill_multiboot_mmap (struct multiboot_tag_mmap *tag)
|
|||
{
|
||||
struct multiboot_mmap_entry *mmap_entry = tag->entries;
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
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_memory_type_t type)
|
||||
{
|
||||
mmap_entry->addr = addr;
|
||||
mmap_entry->len = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
break;
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE
|
||||
case GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE:
|
||||
case GRUB_MEMORY_ACPI:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MEMORY_NVS
|
||||
case GRUB_MACHINE_MEMORY_NVS:
|
||||
case GRUB_MEMORY_NVS:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_NVS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <grub/gzio.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/memory.h>
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
|
||||
|
@ -182,8 +183,10 @@ alloc_phys (grub_addr_t size)
|
|||
{
|
||||
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);
|
||||
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,
|
||||
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;
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
|
||||
|
||||
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_efi_uintn_t mmap_size = 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:
|
||||
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;
|
||||
|
||||
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_RUNTIME_SERVICES_DATA:
|
||||
case GRUB_EFI_UNUSABLE_MEMORY:
|
||||
case GRUB_EFI_MEMORY_MAPPED_IO:
|
||||
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
||||
case GRUB_EFI_PAL_CODE:
|
||||
hook (desc->physical_start, desc->num_pages * 4096,
|
||||
GRUB_MACHINE_MEMORY_RESERVED);
|
||||
GRUB_MEMORY_RESERVED);
|
||||
break;
|
||||
|
||||
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_CONVENTIONAL_MEMORY:
|
||||
hook (desc->physical_start, desc->num_pages * 4096,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE);
|
||||
GRUB_MEMORY_AVAILABLE);
|
||||
break;
|
||||
|
||||
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
|
||||
hook (desc->physical_start, desc->num_pages * 4096,
|
||||
GRUB_MACHINE_MEMORY_ACPI);
|
||||
GRUB_MEMORY_ACPI);
|
||||
break;
|
||||
|
||||
case GRUB_EFI_ACPI_MEMORY_NVS:
|
||||
hook (desc->physical_start, desc->num_pages * 4096,
|
||||
GRUB_MACHINE_MEMORY_NVS);
|
||||
GRUB_MEMORY_NVS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -115,29 +117,26 @@ make_efi_memtype (int type)
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_CODE:
|
||||
case GRUB_MEMORY_CODE:
|
||||
return GRUB_EFI_RUNTIME_SERVICES_CODE;
|
||||
|
||||
/* No way to remove a chunk of memory from EFI mmap.
|
||||
So mark it as unusable. */
|
||||
case GRUB_MACHINE_MEMORY_HOLE:
|
||||
|
||||
default:
|
||||
|
||||
case GRUB_MACHINE_MEMORY_RESERVED:
|
||||
case GRUB_MEMORY_HOLE:
|
||||
case GRUB_MEMORY_RESERVED:
|
||||
return GRUB_EFI_UNUSABLE_MEMORY;
|
||||
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
return GRUB_EFI_CONVENTIONAL_MEMORY;
|
||||
|
||||
case GRUB_MACHINE_MEMORY_ACPI:
|
||||
return GRUB_EFI_ACPI_RECLAIM_MEMORY;
|
||||
|
||||
case GRUB_MACHINE_MEMORY_NVS:
|
||||
case GRUB_MEMORY_ACPI:
|
||||
return GRUB_EFI_ACPI_RECLAIM_MEMORY;
|
||||
|
||||
case GRUB_MEMORY_NVS:
|
||||
return GRUB_EFI_ACPI_MEMORY_NVS;
|
||||
}
|
||||
|
||||
return GRUB_EFI_UNUSABLE_MEMORY;
|
||||
}
|
||||
|
||||
struct overlay
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/i386/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/err.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;
|
||||
|
||||
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,
|
||||
grub_uint32_t memtype)
|
||||
grub_memory_type_t memtype)
|
||||
{
|
||||
grub_uint64_t end = start + rangesize;
|
||||
if (memtype != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (memtype != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (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,
|
||||
grub_uint32_t);
|
||||
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);
|
||||
hookmmapcur->addr = addr;
|
||||
|
@ -135,7 +135,7 @@ malloc_hook (void)
|
|||
grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type __attribute__ ((unused)))
|
||||
{
|
||||
regcount++;
|
||||
return 0;
|
||||
|
@ -172,7 +172,7 @@ malloc_hook (void)
|
|||
reentry = 1;
|
||||
hooktarget
|
||||
= grub_mmap_malign_and_register (16, hooksize, &mmapregion,
|
||||
GRUB_MACHINE_MEMORY_RESERVED,
|
||||
GRUB_MEMORY_RESERVED,
|
||||
GRUB_MMAP_MALLOC_LOW);
|
||||
reentry = 0;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/memory.h>
|
||||
#include <grub/i386/memory.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
|
@ -26,11 +27,12 @@ grub_mmap_get_lower (void)
|
|||
{
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (addr == 0)
|
||||
lower = size;
|
||||
|
@ -48,11 +50,12 @@ grub_mmap_get_upper (void)
|
|||
{
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (addr <= 0x100000 && addr + size > 0x100000)
|
||||
upper = addr + size - 0x100000;
|
||||
|
@ -69,11 +72,12 @@ grub_mmap_get_post64 (void)
|
|||
{
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (addr <= 0x4000000 && addr + size > 0x4000000)
|
||||
post64 = addr + size - 0x4000000;
|
||||
|
|
|
@ -27,11 +27,12 @@ grub_mmap_get_lower (void)
|
|||
{
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (addr == 0)
|
||||
lower = size;
|
||||
|
@ -49,11 +50,12 @@ grub_mmap_get_upper (void)
|
|||
{
|
||||
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,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
if (addr <= GRUB_ARCH_HIGHMEMPSTART && addr + size
|
||||
> GRUB_ARCH_HIGHMEMPSTART)
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
@ -34,8 +34,7 @@ static int curhandle = 1;
|
|||
#endif
|
||||
|
||||
grub_err_t
|
||||
grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||
grub_uint64_t, grub_uint32_t))
|
||||
grub_mmap_iterate (grub_memory_hook_t hook)
|
||||
{
|
||||
|
||||
/* 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
|
||||
4 - a range deliberately empty
|
||||
*/
|
||||
int priority[GRUB_MACHINE_MEMORY_MAX_TYPE + 2] =
|
||||
int priority[] =
|
||||
{
|
||||
#ifdef GRUB_MACHINE_MEMORY_AVAILABLE
|
||||
[GRUB_MACHINE_MEMORY_AVAILABLE] = 1,
|
||||
#endif
|
||||
#if defined (GRUB_MACHINE_MEMORY_RESERVED) && GRUB_MACHINE_MEMORY_RESERVED != GRUB_MACHINE_MEMORY_HOLE
|
||||
[GRUB_MACHINE_MEMORY_RESERVED] = 3,
|
||||
#endif
|
||||
#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,
|
||||
[GRUB_MEMORY_AVAILABLE] = 1,
|
||||
[GRUB_MEMORY_RESERVED] = 3,
|
||||
[GRUB_MEMORY_ACPI] = 2,
|
||||
[GRUB_MEMORY_CODE] = 3,
|
||||
[GRUB_MEMORY_NVS] = 3,
|
||||
[GRUB_MEMORY_HOLE] = 4,
|
||||
};
|
||||
|
||||
int i, k, done;
|
||||
int i, done;
|
||||
|
||||
/* Scanline events. */
|
||||
struct grub_mmap_scan
|
||||
|
@ -89,7 +78,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
/* Current scanline event. */
|
||||
int curtype;
|
||||
/* 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. */
|
||||
int mmap_num;
|
||||
|
||||
|
@ -101,7 +90,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type __attribute__ ((unused)))
|
||||
{
|
||||
mmap_num++;
|
||||
return 0;
|
||||
|
@ -111,17 +100,17 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr,
|
||||
grub_uint64_t size,
|
||||
grub_uint32_t type)
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
scanline_events[i].pos = addr;
|
||||
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;
|
||||
else
|
||||
{
|
||||
grub_dprintf ("mmap", "Unknown memory type %d. Assuming unusable\n",
|
||||
type);
|
||||
scanline_events[i].memtype = GRUB_MACHINE_MEMORY_RESERVED;
|
||||
scanline_events[i].memtype = GRUB_MEMORY_RESERVED;
|
||||
}
|
||||
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].type = 0;
|
||||
if (cur->type == GRUB_MACHINE_MEMORY_HOLE
|
||||
|| (cur->type >= 0 && cur->type <= GRUB_MACHINE_MEMORY_MAX_TYPE
|
||||
&& priority[cur->type]))
|
||||
if (cur->type < ARRAY_SIZE (priority) && priority[cur->type])
|
||||
scanline_events[i].memtype = cur->type;
|
||||
else
|
||||
scanline_events[i].memtype = GRUB_MACHINE_MEMORY_RESERVED;
|
||||
scanline_events[i].memtype = GRUB_MEMORY_RESERVED;
|
||||
i++;
|
||||
|
||||
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;
|
||||
for (i = 0; i < 2 * mmap_num; i++)
|
||||
{
|
||||
unsigned k;
|
||||
/* Process event. */
|
||||
if (scanline_events[i].type)
|
||||
present[scanline_events[i].memtype]--;
|
||||
|
@ -209,7 +197,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
|
||||
/* Determine current region type. */
|
||||
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]))
|
||||
curtype = k;
|
||||
|
||||
|
@ -217,7 +205,7 @@ grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
if ((curtype == -1 || curtype != lasttype)
|
||||
&& lastaddr != scanline_events[i].pos
|
||||
&& lasttype != -1
|
||||
&& lasttype != GRUB_MACHINE_MEMORY_HOLE
|
||||
&& lasttype != GRUB_MEMORY_HOLE
|
||||
&& hook (lastaddr, scanline_events[i].pos - lastaddr, lasttype))
|
||||
{
|
||||
grub_free (scanline_events);
|
||||
|
@ -324,10 +312,11 @@ grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)),
|
|||
char * str;
|
||||
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,
|
||||
grub_uint64_t size,
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
grub_memory_type_t type __attribute__ ((unused)))
|
||||
{
|
||||
grub_uint64_t iterator, low, high, cur;
|
||||
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",
|
||||
(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;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/serial.h>
|
||||
#include <grub/ns8250.h>
|
||||
#include <grub/types.h>
|
||||
|
@ -26,6 +25,7 @@
|
|||
#include <grub/mm.h>
|
||||
|
||||
#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;
|
||||
#define GRUB_SERIAL_PORT_NUM 4
|
||||
#else
|
||||
|
|
|
@ -34,17 +34,6 @@ static inline grub_err_t grub_autoefi_prepare (void)
|
|||
{
|
||||
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_VAR(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_prepare grub_efiemu_prepare
|
||||
# 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_VAR GRUB_EFIEMU_SYSTEM_TABLE_VAR
|
||||
# define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR
|
||||
|
|
|
@ -24,16 +24,6 @@
|
|||
|
||||
#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_uint64_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);
|
||||
grub_err_t
|
||||
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*/
|
||||
typedef enum {GRUB_EFIEMU_NOTLOADED,
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#define _GRUB_MEMORY_MACHINE_LB_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/i386/pc/memory.h>
|
||||
|
||||
#ifndef ASM_FILE
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/memory.h>
|
||||
#endif
|
||||
|
||||
#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */
|
||||
|
@ -35,36 +35,21 @@
|
|||
|
||||
#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);
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
|
||||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
||||
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
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/i386/coreboot/memory.h>
|
||||
|
|
|
@ -30,6 +30,14 @@
|
|||
|
||||
#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;
|
||||
|
||||
static inline grub_phys_addr_t
|
||||
|
|
|
@ -88,51 +88,9 @@ struct grub_machine_bios_data_area
|
|||
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,
|
||||
int type, 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
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define _GRUB_MEMORY_MACHINE_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/i386/coreboot/memory.h>
|
||||
|
||||
#ifndef ASM_FILE
|
||||
#include <grub/err.h>
|
||||
|
@ -37,9 +37,6 @@
|
|||
|
||||
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 /* ! _GRUB_MEMORY_MACHINE_HEADER */
|
||||
|
|
|
@ -22,11 +22,32 @@
|
|||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/machine/memory.h>
|
||||
|
||||
grub_err_t grub_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||
grub_uint64_t,
|
||||
grub_uint32_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_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);
|
||||
grub_err_t grub_mmap_unregister (int handle);
|
||||
|
||||
|
@ -42,7 +63,7 @@ struct grub_mmap_region
|
|||
struct grub_mmap_region *next;
|
||||
grub_uint64_t start;
|
||||
grub_uint64_t end;
|
||||
int type;
|
||||
grub_memory_type_t type;
|
||||
int handle;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x80f00000
|
||||
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
|
||||
|
||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
||||
|
||||
#ifndef ASM_FILE
|
||||
grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate)
|
||||
(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_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
|
||||
|
||||
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…
Reference in a new issue