]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/commands/efi/lsefisystab.c: New file.
authorTristan Gingold <gingold@free.fr>
Wed, 1 Sep 2010 00:37:17 +0000 (02:37 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 1 Sep 2010 00:37:17 +0000 (02:37 +0200)
* grub-core/commands/efi/lssal.c: Likewise.
* grub-core/Makefile.core.def (lsacpi): New module.
(lsefisystab): Likewise.
* include/grub/efi/api.h (GRUB_EFI_SAL_TABLE_GUID): New definition.
(GRUB_EFI_HCDP_TABLE_GUID): Likewise.
(grub_efi_sal_system_table): New struct.
(grub_efi_sal_system_table_entrypoint_descriptor): Likewise.
(grub_efi_sal_system_table_memory_descriptor): Likewise.
(grub_efi_sal_system_table_platform_features): Likewise.
(grub_efi_sal_system_table_translation_register_descriptor): Likewise.
(grub_efi_sal_system_table_purge_translation_coherence): Likewise.
(grub_efi_sal_system_table_ap_wakeup): Likewise.
* include/grub/types.h (PRIuGRUB_UINT64_T): New definition.

Also-By: Robert Millan <rmh.grub@aybabtu.com>
Also-By: Vladimir Serbinenko <phcoder@gmail.com>
ChangeLog.gingold2 [new file with mode: 0644]
grub-core/Makefile.core.def
grub-core/commands/efi/lsefisystab.c [new file with mode: 0644]
grub-core/commands/efi/lssal.c [new file with mode: 0644]
include/grub/efi/api.h
include/grub/types.h

diff --git a/ChangeLog.gingold2 b/ChangeLog.gingold2
new file mode 100644 (file)
index 0000000..517a2cc
--- /dev/null
@@ -0,0 +1,18 @@
+2008-01-28  Tristan Gingold  <gingold@free.fr>
+2010-01-18  Robert Millan  <rmh.grub@aybabtu.com>
+2010-08-31  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/commands/efi/lsefisystab.c: New file.
+       * grub-core/commands/efi/lssal.c: Likewise.
+       * grub-core/Makefile.core.def (lsacpi): New module.
+       (lsefisystab): Likewise.
+       * include/grub/efi/api.h (GRUB_EFI_SAL_TABLE_GUID): New definition.
+       (GRUB_EFI_HCDP_TABLE_GUID): Likewise.
+       (grub_efi_sal_system_table): New struct.
+       (grub_efi_sal_system_table_entrypoint_descriptor): Likewise.
+       (grub_efi_sal_system_table_memory_descriptor): Likewise.
+       (grub_efi_sal_system_table_platform_features): Likewise.
+       (grub_efi_sal_system_table_translation_register_descriptor): Likewise.
+       (grub_efi_sal_system_table_purge_translation_coherence): Likewise.
+       (grub_efi_sal_system_table_ap_wakeup): Likewise.
+       * include/grub/types.h (PRIuGRUB_UINT64_T): New definition.
index 6f116770e41faaf8201bb92c5a737c2d752dfa13..f9cf382f25c52f2d8bdb2e5599149ece5c29fcf6 100644 (file)
@@ -425,6 +425,22 @@ module = {
   enable = i386_multiboot;
 };
 
+module = {
+  name = lsefisystab;
+
+  common = commands/efi/lsefisystab.c;
+
+  enable = x86_efi;
+};
+
+module = {
+  name = lssal;
+
+  common = commands/efi/lssal.c;
+
+  enable = x86_efi;
+};
+
 module = {
   name = blocklist;
   common = commands/blocklist.c;
diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
new file mode 100644 (file)
index 0000000..90f7bf0
--- /dev/null
@@ -0,0 +1,106 @@
+/* systab.c  - Display EFI systab.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/charset.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+
+struct guid_mapping
+{
+  grub_efi_guid_t guid;
+  const char *name;
+};
+
+static const struct guid_mapping guid_mappings[] =
+  {
+    { GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
+    { GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
+    { GRUB_EFI_SAL_TABLE_GUID, "SAL"},
+    { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
+    { GRUB_EFI_MPS_TABLE_GUID, "MPS"},
+    { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}
+  };
+
+static grub_err_t
+grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
+                     int argc __attribute__ ((unused)),
+                     char **args __attribute__ ((unused)))
+{
+  const grub_efi_system_table_t *st = grub_efi_system_table;
+  grub_efi_configuration_table_t *t;
+  unsigned int i;
+
+  grub_printf ("Signature: %016" PRIxGRUB_UINT64_T " revision: %08x\n",
+              st->hdr.signature, st->hdr.revision);
+  {
+    char *vendor;
+    grub_uint16_t *vendor_utf16;
+    grub_printf ("Vendor: ");
+    
+    for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
+    vendor = grub_malloc (4 * (vendor_utf16 - st->firmware_vendor) + 1);
+    if (!vendor)
+      return grub_errno;
+    *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor,
+                        vendor_utf16 - st->firmware_vendor) = 0;
+    grub_printf ("%s", vendor);
+  }
+
+  grub_printf (", Version=%x\n", st->firmware_revision);
+
+  grub_printf ("%ld tables:\n", st->num_table_entries);
+  t = st->configuration_table;
+  for (i = 0; i < st->num_table_entries; i++)
+    {
+      unsigned int j;
+
+      grub_printf ("%p  ", t->vendor_table);
+
+      grub_printf ("%08x-%04x-%04x-",
+                  t->vendor_guid.data1, t->vendor_guid.data2,
+                  t->vendor_guid.data3);
+      for (j = 0; j < 8; j++)
+       grub_printf ("%02x", t->vendor_guid.data4[j]);
+      
+      for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
+       if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
+                        sizeof (grub_efi_guid_t)) == 0)
+         grub_printf ("   %s", guid_mappings[j].name);
+
+      grub_printf ("\n");
+      t++;
+    }
+  return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsefisystab)
+{
+  cmd = grub_register_command ("lsefisystab", grub_cmd_lsefisystab, 
+                              "", "Display EFI system tables.");
+}
+
+GRUB_MOD_FINI(lsefisystab)
+{
+  grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/efi/lssal.c b/grub-core/commands/efi/lssal.c
new file mode 100644 (file)
index 0000000..245883f
--- /dev/null
@@ -0,0 +1,162 @@
+/* systab.c  - Display EFI systab.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/charset.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+
+static void
+disp_sal (void *table)
+{
+  struct grub_efi_sal_system_table *t = table;
+  void *desc;
+  grub_uint32_t len, l;
+
+  grub_printf ("SAL rev: %02x, signature: %x, len:%x\n",
+              t->sal_rev, t->signature, t->total_table_len);
+  grub_printf ("nbr entry: %d, chksum: %02x, SAL version A: %02x B: %02x\n",
+              t->entry_count, t->checksum,
+              t->sal_a_version, t->sal_b_version);
+  grub_printf ("OEM-ID: %-32s\n", t->oem_id);
+  grub_printf ("Product-ID: %-32s\n", t->product_id);
+
+  desc = t->entries;
+  len = t->total_table_len - sizeof (struct grub_efi_sal_system_table);
+  while (len > 0)
+    {
+      switch (*(grub_uint8_t *) desc)
+       {
+       case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR:
+         {
+           struct grub_efi_sal_system_table_entrypoint_descriptor *c = desc;
+           l = sizeof (*c);
+           grub_printf (" Entry point: PAL=%016" PRIxGRUB_UINT64_T
+                        " SAL=%016" PRIxGRUB_UINT64_T " GP=%016"
+                        PRIxGRUB_UINT64_T "\n",
+                        c->pal_proc_addr, c->sal_proc_addr,
+                        c->global_data_ptr);
+         }
+         break;
+       case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR:
+         {
+           struct grub_efi_sal_system_table_memory_descriptor *c = desc;
+           l = sizeof (*c);
+           grub_printf (" Memory descriptor entry addr=%016" PRIxGRUB_UINT64_T
+                        " len=%" PRIuGRUB_UINT64_T "KB\n",
+                        c->addr, c->len * 4);
+           grub_printf ("     sal_used=%d attr=%x AR=%x attr_mask=%x "
+                        "type=%x usage=%x\n",
+                        c->sal_used, c->attr, c->ar, c->attr_mask, c->mem_type,
+                        c->usage);
+         }
+         break;
+       case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES:
+         {
+           struct grub_efi_sal_system_table_platform_features *c = desc;
+           l = sizeof (*c);
+           grub_printf (" Platform features: %02x", c->flags);
+           if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK)
+             grub_printf (" BusLock");
+           if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT)
+             grub_printf (" IrqRedirect");
+           if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT)
+
+             grub_printf (" IPIRedirect");
+           if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT)
+
+             grub_printf (" ITCDrift");
+           grub_printf ("\n");
+         }
+         break;
+       case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR:
+         {
+           struct grub_efi_sal_system_table_translation_register_descriptor *c
+             = desc;
+           l = sizeof (*c);
+           grub_printf (" TR type=%d num=%d va=%016" PRIxGRUB_UINT64_T
+                        " pte=%016" PRIxGRUB_UINT64_T "\n",
+                        c->register_type, c->register_number,
+                        c->addr, c->page_size);
+         }
+         break;
+       case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE:
+         {
+           struct grub_efi_sal_system_table_purge_translation_coherence *c
+             = desc;
+           l = sizeof (*c);
+           grub_printf (" PTC coherence nbr=%d addr=%016" PRIxGRUB_UINT64_T "\n",
+                        c->ndomains, c->coherence);
+         }
+         break;
+       case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP:
+         {
+           struct grub_efi_sal_system_table_ap_wakeup *c = desc;
+           l = sizeof (*c);
+           grub_printf (" AP wake-up: mec=%d vect=%" PRIxGRUB_UINT64_T "\n",
+                        c->mechanism, c->vector);
+         }
+         break;
+       default:
+         grub_printf (" unknown entry 0x%x\n", *(grub_uint8_t *)desc);
+         return;
+       }
+      desc = (grub_uint8_t *)desc + l;
+      len -= l;
+    }
+}
+
+static grub_err_t
+grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
+               int argc __attribute__ ((unused)),
+               char **args __attribute__ ((unused)))
+{
+  const grub_efi_system_table_t *st = grub_efi_system_table;
+  grub_efi_configuration_table_t *t = st->configuration_table;
+  unsigned int i;
+  grub_efi_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
+
+  for (i = 0; i < st->num_table_entries; i++)
+    {
+      if (grub_memcmp (&guid, &t->vendor_guid,
+                      sizeof (grub_efi_guid_t)) == 0)
+       {
+         disp_sal (t->vendor_table);
+         return GRUB_ERR_NONE;
+       }
+      t++;
+    }
+  grub_printf ("SAL not found\n");
+  return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lssal)
+{
+  cmd = grub_register_command ("lssal", grub_cmd_lssal, "",
+                              "Display SAL system table.");
+}
+
+GRUB_MOD_FINI(lssal)
+{
+  grub_unregister_command (cmd);
+}
index 36363ae1e99bd5c2f8e3bcb32f8307b9b7389496..5eededdc2a6cd499e7c1164e9e079684c79425cc 100644 (file)
     { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
   }
 
+#define GRUB_EFI_SAL_TABLE_GUID \
+  { 0xeb9d2d32, 0x2d88, 0x11d3, \
+      { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+  }
+
+#define GRUB_EFI_HCDP_TABLE_GUID \
+  { 0xf951938d, 0x620b, 0x42ef, \
+      { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
+  }
+
+struct grub_efi_sal_system_table
+{
+  grub_uint32_t signature;
+  grub_uint32_t total_table_len;
+  grub_uint16_t sal_rev;
+  grub_uint16_t entry_count;
+  grub_uint8_t checksum;
+  grub_uint8_t reserved1[7];
+  grub_uint16_t sal_a_version;
+  grub_uint16_t sal_b_version;
+  grub_uint8_t oem_id[32];
+  grub_uint8_t product_id[32];
+  grub_uint8_t reserved2[8];
+  grub_uint8_t entries[0];
+};
+
+enum
+  {
+    GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR = 0,
+    GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR = 1,
+    GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES = 2,
+    GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR = 3,
+    GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE = 4,
+    GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP = 5
+  };
+
+struct grub_efi_sal_system_table_entrypoint_descriptor
+{
+  grub_uint8_t type;
+  grub_uint8_t pad[7];
+  grub_uint64_t pal_proc_addr;
+  grub_uint64_t sal_proc_addr;
+  grub_uint64_t global_data_ptr;
+  grub_uint64_t reserved[2];
+};
+
+struct grub_efi_sal_system_table_memory_descriptor
+{
+  grub_uint8_t type;
+  grub_uint8_t sal_used;
+  grub_uint8_t attr;
+  grub_uint8_t ar;
+  grub_uint8_t attr_mask;
+  grub_uint8_t mem_type;
+  grub_uint8_t usage;
+  grub_uint8_t unknown;
+  grub_uint64_t addr;
+  grub_uint64_t len;
+  grub_uint64_t unknown2;
+};
+
+struct grub_efi_sal_system_table_platform_features
+{
+  grub_uint8_t type;
+  grub_uint8_t flags;
+  grub_uint8_t reserved[14];
+};
+
+struct grub_efi_sal_system_table_translation_register_descriptor
+{
+  grub_uint8_t type;
+  grub_uint8_t register_type;
+  grub_uint8_t register_number;
+  grub_uint8_t reserved[5];
+  grub_uint64_t addr;
+  grub_uint64_t page_size;
+  grub_uint64_t reserver;
+};
+
+struct grub_efi_sal_system_table_purge_translation_coherence
+{
+  grub_uint8_t type;
+  grub_uint8_t reserved[3];  
+  grub_uint32_t ndomains;
+  grub_uint64_t coherence;
+};
+
+struct grub_efi_sal_system_table_ap_wakeup
+{
+  grub_uint8_t type;
+  grub_uint8_t mechanism;
+  grub_uint8_t reserved[6];
+  grub_uint64_t vector;
+};
+
+enum
+  {
+    GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK = 1,
+    GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT = 2,
+    GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT = 4,
+    GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT = 8,
+  };
+
 /* Enumerations.  */
 enum grub_efi_timer_delay
   {
index 1cabc2ecfe664d16daa0ebd099b9c3dc11ad3ebb..766eddf0792f57b624b0aec12883314ee3839214 100644 (file)
@@ -74,9 +74,11 @@ typedef unsigned             grub_uint32_t;
 #if GRUB_CPU_SIZEOF_LONG == 8
 typedef unsigned long          grub_uint64_t;
 # define PRIxGRUB_UINT64_T     "lx"
+# define PRIuGRUB_UINT64_T     "lu"
 #else
 typedef unsigned long long     grub_uint64_t;
 # define PRIxGRUB_UINT64_T     "llx"
+# define PRIuGRUB_UINT64_T     "llu"
 #endif
 
 /* Misc types.  */