cmosdump.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2009,2013 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. #include <grub/dl.h>
  19. #include <grub/command.h>
  20. #include <grub/misc.h>
  21. #include <grub/cmos.h>
  22. #include <grub/i18n.h>
  23. GRUB_MOD_LICENSE ("GPLv3+");
  24. static grub_err_t
  25. grub_cmd_cmosdump (struct grub_command *cmd __attribute__ ((unused)),
  26. int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused)))
  27. {
  28. int i;
  29. for (i = 0; i < 256; i++)
  30. {
  31. grub_err_t err;
  32. grub_uint8_t value;
  33. if ((i & 0xf) == 0)
  34. grub_printf ("%02x: ", i);
  35. err = grub_cmos_read (i, &value);
  36. if (err)
  37. return err;
  38. grub_printf ("%02x ", value);
  39. if ((i & 0xf) == 0xf)
  40. grub_printf ("\n");
  41. }
  42. return GRUB_ERR_NONE;
  43. }
  44. static grub_command_t cmd;
  45. GRUB_MOD_INIT(cmosdump)
  46. {
  47. cmd = grub_register_command ("cmosdump", grub_cmd_cmosdump,
  48. 0,
  49. N_("Show raw dump of the CMOS contents."));
  50. }
  51. GRUB_MOD_FINI(cmosdump)
  52. {
  53. grub_unregister_command (cmd);
  54. }