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
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
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
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
#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>
#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>
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;
"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;
playground = playground_ptr
= grub_mmap_malign_and_register (1, playground_size, &mmapregion,
- GRUB_MACHINE_MEMORY_ACPI, 0);
+ GRUB_MEMORY_ACPI, 0);
if (! playground)
{
#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. */
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 "
* 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
*/
#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>
#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
{
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;
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);
}
}
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;
{
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:
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;
}
#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>
/* 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. */
size = GRUB_ULONG_MAX - addr;
#endif
- if (type != GRUB_MACHINE_MEMORY_AVAILABLE)
+ if (type != GRUB_MEMORY_AVAILABLE)
return 0;
/* Avoid the lower memory. */
*/
#include <grub/machine/memory.h>
+#include <grub/machine/lbio.h>
#include <grub/types.h>
#include <grub/err.h>
#include <grub/misc.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)
{
mem_region_t mem_region;
*/
#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>
*/
#include <grub/symbol.h>
-#include <grub/machine/memory.h>
+#include <grub/offsets.h>
#include <grub/cpu/linux.h>
#include <multiboot.h>
#include <multiboot2.h>
#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;
}
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;
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)
}
/* Ignore >4GB. */
- if (addr <= 0xFFFFFFFF && type == GRUB_MACHINE_MEMORY_AVAILABLE)
+ if (addr <= 0xFFFFFFFF && type == GRUB_MEMORY_AVAILABLE)
{
grub_size_t len;
#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
}
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
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)
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;
* 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
}
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;
#include <config.h>
#include <grub/symbol.h>
+
+#include <grub/i386/pc/memory.h>
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#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)
{
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;
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
grub_ieee1275_init ();
grub_console_init_early ();
-#ifdef __i386__
- grub_get_extended_memory ();
-#endif
grub_claim_heap ();
grub_console_init_lately ();
grub_ofdisk_init ();
* 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;
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;
}
}
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;
}
#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>
}
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;
}
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;
{
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))
{
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)
#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>
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;
}
*/
#include <grub/loader.h>
-#include <grub/machine/memory.h>
#include <grub/memory.h>
#include <grub/normal.h>
#include <grub/file.h>
{
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;
/* 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)
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,
* 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>
{
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;
#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>
#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>
#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. */
#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>
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;
* 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>
{
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;
#include <grub/gzio.h>
#include <grub/command.h>
#include <grub/i18n.h>
+#include <grub/memory.h>
static grub_dl_t my_mod;
{
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;
((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;
{
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:
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:
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;
}
}
{
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
*/
#include <grub/machine/memory.h>
+#include <grub/i386/memory.h>
#include <grub/memory.h>
#include <grub/err.h>
#include <grub/misc.h>
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;
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;
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;
reentry = 1;
hooktarget
= grub_mmap_malign_and_register (16, hooksize, &mmapregion,
- GRUB_MACHINE_MEMORY_RESERVED,
+ GRUB_MEMORY_RESERVED,
GRUB_MMAP_MALLOC_LOW);
reentry = 0;
*/
#include <grub/memory.h>
+#include <grub/i386/memory.h>
#include <grub/mm.h>
#include <grub/misc.h>
{
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;
{
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;
{
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;
{
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;
{
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)
* 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>
#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.
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
/* 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;
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;
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++;
{
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;
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]--;
/* 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;
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);
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;
{
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;
}
* 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>
#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
{
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))
# 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
#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));
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,
#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 */
#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;
+void grub_machine_mmap_init (void);
-struct grub_linuxbios_table_item
+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)))
{
-#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
+ return GRUB_ERR_NONE;
+}
+static inline grub_err_t
+grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
{
- 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));
+ return GRUB_ERR_NONE;
+}
#endif
-#include <grub/i386/pc/memory.h>
+#include <grub/i386/coreboot/memory.h>
#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
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
#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>
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 */
#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);
struct grub_mmap_region *next;
grub_uint64_t start;
grub_uint64_t end;
- int type;
+ grub_memory_type_t type;
int handle;
};
#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));
#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;
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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