vaseboot/include/VasEBoot/memory.h

88 lines
2.8 KiB
C

/* memory.h - describe the memory map */
/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2002,2007,2008 Free Software Foundation, Inc.
*
* VasEBoot 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.
*
* VasEBoot 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 VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VasEBoot_MEMORY_HEADER
#define VasEBoot_MEMORY_HEADER 1
#include <VasEBoot/types.h>
#include <VasEBoot/err.h>
typedef enum VasEBoot_memory_type
{
VasEBoot_MEMORY_AVAILABLE = 1,
VasEBoot_MEMORY_RESERVED = 2,
VasEBoot_MEMORY_ACPI = 3,
VasEBoot_MEMORY_NVS = 4,
VasEBoot_MEMORY_BADRAM = 5,
VasEBoot_MEMORY_PERSISTENT = 7,
VasEBoot_MEMORY_PERSISTENT_LEGACY = 12,
VasEBoot_MEMORY_COREBOOT_TABLES = 16,
VasEBoot_MEMORY_CODE = 20,
/* This one is special: it's used internally but is never reported
by firmware. Don't use -1 as it's used internally for other purposes. */
VasEBoot_MEMORY_HOLE = -2,
VasEBoot_MEMORY_MAX = 0x10000
} VasEBoot_memory_type_t;
typedef int (*VasEBoot_memory_hook_t) (VasEBoot_uint64_t,
VasEBoot_uint64_t,
VasEBoot_memory_type_t,
void *);
VasEBoot_err_t VasEBoot_mmap_iterate (VasEBoot_memory_hook_t hook, void *hook_data);
#ifdef VasEBoot_MACHINE_EFI
VasEBoot_err_t
VasEBoot_efi_mmap_iterate (VasEBoot_memory_hook_t hook, void *hook_data,
int avoid_efi_boot_services);
#endif
#if !defined (VasEBoot_MACHINE_EMU) && !defined (VasEBoot_MACHINE_EFI)
VasEBoot_err_t EXPORT_FUNC(VasEBoot_machine_mmap_iterate) (VasEBoot_memory_hook_t hook,
void *hook_data);
#else
VasEBoot_err_t VasEBoot_machine_mmap_iterate (VasEBoot_memory_hook_t hook,
void *hook_data);
#endif
int VasEBoot_mmap_register (VasEBoot_uint64_t start, VasEBoot_uint64_t size, int type);
VasEBoot_err_t VasEBoot_mmap_unregister (int handle);
void *VasEBoot_mmap_malign_and_register (VasEBoot_uint64_t align, VasEBoot_uint64_t size,
int *handle, int type, int flags);
void VasEBoot_mmap_free_and_unregister (int handle);
#ifndef VasEBoot_MMAP_REGISTER_BY_FIRMWARE
struct VasEBoot_mmap_region
{
struct VasEBoot_mmap_region *next;
VasEBoot_uint64_t start;
VasEBoot_uint64_t end;
VasEBoot_memory_type_t type;
int handle;
int priority;
};
extern struct VasEBoot_mmap_region *VasEBoot_mmap_overlays;
#endif
#endif /* ! VasEBoot_MEMORY_HEADER */