2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/misc.h>
21 #include <grub/command.h>
22 #include <grub/i18n.h>
23 #include <grub/memory.h>
26 GRUB_MOD_LICENSE ("GPLv3+");
28 #ifndef GRUB_MACHINE_EMU
29 static const char *names
[] =
31 [GRUB_MEMORY_AVAILABLE
] = N_("available RAM"),
32 [GRUB_MEMORY_RESERVED
] = N_("reserved RAM"),
33 /* TRANSLATORS: this refers to memory where ACPI tables are stored
34 and which can be used by OS once it loads ACPI tables. */
35 [GRUB_MEMORY_ACPI
] = N_("ACPI reclaimable RAM"),
36 /* TRANSLATORS: this refers to memory which ACPI-compliant OS
37 is required to save accross hibernations. */
38 [GRUB_MEMORY_NVS
] = N_("ACPI non-volatile storage RAM"),
39 [GRUB_MEMORY_BADRAM
] = N_("faulty RAM (BadRAM)"),
40 [GRUB_MEMORY_COREBOOT_TABLES
] = N_("RAM holding coreboot tables"),
41 [GRUB_MEMORY_CODE
] = N_("RAM holding firmware code")
44 /* Helper for grub_cmd_lsmmap. */
46 lsmmap_hook (grub_uint64_t addr
, grub_uint64_t size
, grub_memory_type_t type
,
47 void *data
__attribute__ ((unused
)))
49 if (type
< (int) ARRAY_SIZE (names
) && type
>= 0 && names
[type
])
50 grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, %s\n"),
51 (long long) addr
, (long long) size
, _(names
[type
]));
53 grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n"),
54 (long long) addr
, (long long) size
, type
);
60 grub_cmd_lsmmap (grub_command_t cmd
__attribute__ ((unused
)),
61 int argc
__attribute__ ((unused
)),
62 char **args
__attribute__ ((unused
)))
65 #ifndef GRUB_MACHINE_EMU
66 grub_machine_mmap_iterate (lsmmap_hook
, NULL
);
72 static grub_command_t cmd
;
76 cmd
= grub_register_command ("lsmmap", grub_cmd_lsmmap
,
77 0, N_("List memory map provided by firmware."));
82 grub_unregister_command (cmd
);