cbls.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 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/misc.h>
  20. #include <grub/command.h>
  21. #include <grub/i18n.h>
  22. #include <grub/coreboot/lbio.h>
  23. #include <grub/i386/tsc.h>
  24. GRUB_MOD_LICENSE ("GPLv3+");
  25. static const char *console_descs[] = {
  26. "8250 UART",
  27. "VGA",
  28. "BTEXT",
  29. "log buffer console",
  30. "SROM",
  31. "EHCI debug",
  32. "memory-mapped 8250 UART"
  33. };
  34. static const char *descs[] = {
  35. [GRUB_LINUXBIOS_MEMBER_MEMORY] = "memory map (`lsmmap' to list)",
  36. [GRUB_LINUXBIOS_MEMBER_MAINBOARD] = "mainboard",
  37. [4] = "version",
  38. [5] = "extra version",
  39. [6] = "build",
  40. [7] = "compile time",
  41. [8] = "compile by",
  42. [9] = "compile host",
  43. [0xa] = "compile domain",
  44. [0xb] = "compiler",
  45. [0xc] = "linker",
  46. [0xd] = "assembler",
  47. [0xf] = "serial",
  48. [GRUB_LINUXBIOS_MEMBER_CONSOLE] = "console",
  49. [GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER] = "framebuffer",
  50. [0x13] = "GPIO",
  51. [0x15] = "VDAT",
  52. [GRUB_LINUXBIOS_MEMBER_TIMESTAMPS] = "timestamps (`coreboot_boottime' to list)",
  53. [GRUB_LINUXBIOS_MEMBER_CBMEMC] = "CBMEM console (`cbmemc' to list)",
  54. [0x18] = "MRC cache",
  55. [0x19] = "VBNV",
  56. [0xc8] = "CMOS option table",
  57. [0xc9] = "CMOS option",
  58. [0xca] = "CMOS option enum",
  59. [0xcb] = "CMOS option defaults",
  60. [0xcc] = "CMOS checksum",
  61. };
  62. static int
  63. iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
  64. void *data __attribute__ ((unused)))
  65. {
  66. if (table_item->tag < ARRAY_SIZE (descs) && descs[table_item->tag])
  67. grub_printf ("tag=%02x size=%02x %s",
  68. table_item->tag, table_item->size, descs[table_item->tag]);
  69. else
  70. grub_printf ("tag=%02x size=%02x",
  71. table_item->tag, table_item->size);
  72. switch (table_item->tag)
  73. {
  74. case GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER:
  75. {
  76. struct grub_linuxbios_table_framebuffer *fb;
  77. fb = (struct grub_linuxbios_table_framebuffer *) (table_item + 1);
  78. grub_printf (": %dx%dx%d pitch=%d lfb=0x%llx %d/%d/%d/%d %d/%d/%d/%d",
  79. fb->width, fb->height,
  80. fb->bpp, fb->pitch,
  81. (unsigned long long) fb->lfb,
  82. fb->red_mask_size, fb->green_mask_size,
  83. fb->blue_mask_size, fb->reserved_mask_size,
  84. fb->red_field_pos, fb->green_field_pos,
  85. fb->blue_field_pos, fb->reserved_field_pos);
  86. break;
  87. }
  88. case GRUB_LINUXBIOS_MEMBER_MAINBOARD:
  89. {
  90. struct grub_linuxbios_mainboard *mb;
  91. mb = (struct grub_linuxbios_mainboard *) (table_item + 1);
  92. grub_printf (": vendor=`%s' part_number=`%s'",
  93. mb->strings + mb->vendor,
  94. mb->strings + mb->part_number);
  95. break;
  96. }
  97. case 0x04 ... 0x0d:
  98. grub_printf (": `%s'", (char *) (table_item + 1));
  99. break;
  100. case GRUB_LINUXBIOS_MEMBER_CONSOLE:
  101. {
  102. grub_uint16_t *val = (grub_uint16_t *) (table_item + 1);
  103. grub_printf (": id=%d", *val);
  104. if (*val < ARRAY_SIZE (console_descs)
  105. && console_descs[*val])
  106. grub_printf (" %s", console_descs[*val]);
  107. }
  108. }
  109. grub_printf ("\n");
  110. return 0;
  111. }
  112. static grub_err_t
  113. grub_cmd_lscoreboot (struct grub_command *cmd __attribute__ ((unused)),
  114. int argc __attribute__ ((unused)),
  115. char *argv[] __attribute__ ((unused)))
  116. {
  117. grub_linuxbios_table_iterate (iterate_linuxbios_table, 0);
  118. return 0;
  119. }
  120. static grub_command_t cmd;
  121. GRUB_MOD_INIT(cbls)
  122. {
  123. cmd =
  124. grub_register_command ("lscoreboot", grub_cmd_lscoreboot,
  125. 0, N_("List coreboot tables."));
  126. }
  127. GRUB_MOD_FINI(cbls)
  128. {
  129. grub_unregister_command (cmd);
  130. }