2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2008 Free Software Foundation, Inc.
2N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/dl.h>
2N/A#include <grub/misc.h>
2N/A#include <grub/command.h>
2N/A#include <grub/i18n.h>
2N/A#include <grub/memory.h>
2N/A
2N/AGRUB_MOD_LICENSE ("GPLv3+");
2N/A
2N/Astatic const char *names[] =
2N/A {
2N/A [GRUB_MEMORY_AVAILABLE] = N_("available"),
2N/A [GRUB_MEMORY_RESERVED] = N_("reserved"),
2N/A [GRUB_MEMORY_ACPI] = N_("ACPI reclaimable"),
2N/A [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage"),
2N/A [GRUB_MEMORY_BADRAM] = N_("BadRAM"),
2N/A [GRUB_MEMORY_CODE] = N_("firmware code"),
2N/A [GRUB_MEMORY_DATA] = N_("firmware data"),
2N/A [GRUB_MEMORY_HOLE] = N_("hole")
2N/A };
2N/A
2N/Astatic grub_err_t
2N/Agrub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
2N/A int argc __attribute__ ((unused)),
2N/A char **args __attribute__ ((unused)))
2N/A
2N/A{
2N/A auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_memory_type_t);
2N/A int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
2N/A grub_memory_type_t type)
2N/A {
2N/A if (type < ARRAY_SIZE (names) && names[type])
2N/A grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, %s\n"),
2N/A (long long) addr, (long long) size, _(names[type]));
2N/A else
2N/A grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n"),
2N/A (long long) addr, (long long) size, type);
2N/A return 0;
2N/A }
2N/A#ifndef GRUB_MACHINE_EMU
2N/A grub_machine_mmap_iterate (hook);
2N/A#endif
2N/A
2N/A return 0;
2N/A}
2N/A
2N/Astatic grub_command_t cmd;
2N/A
2N/AGRUB_MOD_INIT(lsmmap)
2N/A{
2N/A cmd = grub_register_command ("lsmmap", grub_cmd_lsmmap,
2N/A 0, N_("List memory map provided by firmware."));
2N/A}
2N/A
2N/AGRUB_MOD_FINI(lsmmap)
2N/A{
2N/A grub_unregister_command (cmd);
2N/A}