lsmmap.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2008 Free Software Foundation, Inc.
  4. *
  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.
  9. *
  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.
  14. *
  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/>.
  17. */
  18. #ifndef GRUB_MACHINE_EMU
  19. #include <grub/machine/memory.h>
  20. #endif
  21. #include <grub/dl.h>
  22. #include <grub/misc.h>
  23. #include <grub/command.h>
  24. #include <grub/i18n.h>
  25. #ifndef GRUB_MACHINE_EMU
  26. static int
  27. hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type,
  28. void *closure __attribute__ ((unused)))
  29. {
  30. grub_printf ("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n",
  31. (long long) addr, (long long) size, type);
  32. return 0;
  33. }
  34. #endif
  35. static grub_err_t
  36. grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
  37. int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
  38. {
  39. #ifndef GRUB_MACHINE_EMU
  40. grub_machine_mmap_iterate (hook, 0);
  41. #endif
  42. return 0;
  43. }
  44. static grub_command_t cmd;
  45. GRUB_MOD_INIT(lsmmap)
  46. {
  47. cmd = grub_register_command ("lsmmap", grub_cmd_lsmmap,
  48. 0, N_("List memory map provided by firmware."));
  49. }
  50. GRUB_MOD_FINI(lsmmap)
  51. {
  52. grub_unregister_command (cmd);
  53. }