lssal.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* lssal.c - Display EFI SAL systab. */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2008 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <grub/types.h>
  20. #include <grub/mm.h>
  21. #include <grub/misc.h>
  22. #include <grub/normal.h>
  23. #include <grub/charset.h>
  24. #include <grub/efi/api.h>
  25. #include <grub/efi/efi.h>
  26. #include <grub/dl.h>
  27. GRUB_MOD_LICENSE ("GPLv3+");
  28. static void
  29. disp_sal (void *table)
  30. {
  31. struct grub_efi_sal_system_table *t = table;
  32. void *desc;
  33. grub_uint32_t len, l;
  34. grub_printf ("SAL rev: %02x, signature: %x, len:%x\n",
  35. t->sal_rev, t->signature, t->total_table_len);
  36. grub_printf ("nbr entry: %d, chksum: %02x, SAL version A: %02x B: %02x\n",
  37. t->entry_count, t->checksum,
  38. t->sal_a_version, t->sal_b_version);
  39. grub_printf ("OEM-ID: %-32s\n", t->oem_id);
  40. grub_printf ("Product-ID: %-32s\n", t->product_id);
  41. desc = t->entries;
  42. len = t->total_table_len - sizeof (struct grub_efi_sal_system_table);
  43. while (len > 0)
  44. {
  45. switch (*(grub_uint8_t *) desc)
  46. {
  47. case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR:
  48. {
  49. struct grub_efi_sal_system_table_entrypoint_descriptor *c = desc;
  50. l = sizeof (*c);
  51. grub_printf (" Entry point: PAL=%016" PRIxGRUB_UINT64_T
  52. " SAL=%016" PRIxGRUB_UINT64_T " GP=%016"
  53. PRIxGRUB_UINT64_T "\n",
  54. c->pal_proc_addr, c->sal_proc_addr,
  55. c->global_data_ptr);
  56. }
  57. break;
  58. case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR:
  59. {
  60. struct grub_efi_sal_system_table_memory_descriptor *c = desc;
  61. l = sizeof (*c);
  62. grub_printf (" Memory descriptor entry addr=%016" PRIxGRUB_UINT64_T
  63. " len=%" PRIuGRUB_UINT64_T "KB\n",
  64. c->addr, c->len * 4);
  65. grub_printf (" sal_used=%d attr=%x AR=%x attr_mask=%x "
  66. "type=%x usage=%x\n",
  67. c->sal_used, c->attr, c->ar, c->attr_mask, c->mem_type,
  68. c->usage);
  69. }
  70. break;
  71. case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES:
  72. {
  73. struct grub_efi_sal_system_table_platform_features *c = desc;
  74. l = sizeof (*c);
  75. grub_printf (" Platform features: %02x", c->flags);
  76. if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK)
  77. grub_printf (" BusLock");
  78. if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT)
  79. grub_printf (" IrqRedirect");
  80. if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT)
  81. grub_printf (" IPIRedirect");
  82. if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT)
  83. grub_printf (" ITCDrift");
  84. grub_printf ("\n");
  85. }
  86. break;
  87. case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR:
  88. {
  89. struct grub_efi_sal_system_table_translation_register_descriptor *c
  90. = desc;
  91. l = sizeof (*c);
  92. grub_printf (" TR type=%d num=%d va=%016" PRIxGRUB_UINT64_T
  93. " pte=%016" PRIxGRUB_UINT64_T "\n",
  94. c->register_type, c->register_number,
  95. c->addr, c->page_size);
  96. }
  97. break;
  98. case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE:
  99. {
  100. struct grub_efi_sal_system_table_purge_translation_coherence *c
  101. = desc;
  102. l = sizeof (*c);
  103. grub_printf (" PTC coherence nbr=%d addr=%016" PRIxGRUB_UINT64_T "\n",
  104. c->ndomains, c->coherence);
  105. }
  106. break;
  107. case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP:
  108. {
  109. struct grub_efi_sal_system_table_ap_wakeup *c = desc;
  110. l = sizeof (*c);
  111. grub_printf (" AP wake-up: mec=%d vect=%" PRIxGRUB_UINT64_T "\n",
  112. c->mechanism, c->vector);
  113. }
  114. break;
  115. default:
  116. grub_printf (" unknown entry 0x%x\n", *(grub_uint8_t *)desc);
  117. return;
  118. }
  119. desc = (grub_uint8_t *)desc + l;
  120. len -= l;
  121. }
  122. }
  123. static grub_err_t
  124. grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
  125. int argc __attribute__ ((unused)),
  126. char **args __attribute__ ((unused)))
  127. {
  128. const grub_efi_system_table_t *st = grub_efi_system_table;
  129. grub_efi_configuration_table_t *t = st->configuration_table;
  130. unsigned int i;
  131. grub_efi_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
  132. for (i = 0; i < st->num_table_entries; i++)
  133. {
  134. if (grub_memcmp (&guid, &t->vendor_guid,
  135. sizeof (grub_efi_guid_t)) == 0)
  136. {
  137. disp_sal (t->vendor_table);
  138. return GRUB_ERR_NONE;
  139. }
  140. t++;
  141. }
  142. grub_printf ("SAL not found\n");
  143. return GRUB_ERR_NONE;
  144. }
  145. static grub_command_t cmd;
  146. GRUB_MOD_INIT(lssal)
  147. {
  148. cmd = grub_register_command ("lssal", grub_cmd_lssal, "",
  149. "Display SAL system table.");
  150. }
  151. GRUB_MOD_FINI(lssal)
  152. {
  153. grub_unregister_command (cmd);
  154. }