Unify memory types.

* grub-core/Makefile.am (KERNEL_HEADER_FILES): Include memory.h.
	* grub-core/commands/lsmmap.c (grub_cmd_lsmmap): Output user-readable
	types.
	* grub-core/kern/i386/multiboot_mmap.c (grub_lower_mem): Removed.
	(grub_upper_mem): Likewise.
	* grub-core/kern/ieee1275/init.c (grub_upper_mem): Likewise.
	* include/grub/memory.h (grub_memory_type_t): New enum.
	All users updated.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-19 00:04:31 +02:00
commit a1d84a5e5e
52 changed files with 315 additions and 443 deletions

View file

@ -25,7 +25,6 @@
#include <grub/misc.h>
#include <grub/acpi.h>
#include <grub/mm.h>
#include <grub/machine/memory.h>
#include <grub/memory.h>
#include <grub/i18n.h>
@ -151,10 +150,10 @@ grub_acpi_create_ebda (void)
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
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;
@ -180,7 +179,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;
@ -704,7 +703,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
playground = playground_ptr
= grub_mmap_malign_and_register (1, playground_size, &mmapregion,
GRUB_MACHINE_MEMORY_ACPI, 0);
GRUB_MEMORY_ACPI, 0);
if (! playground)
{

View file

@ -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 "

View file

@ -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