nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone
Blob Blame History Raw
From 1246dfa7e45257c44f175112ab70bcf8d0c84c82 Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Fri, 1 Feb 2013 21:45:39 +0100
Subject: [PATCH 148/482] 	* grub-core/commands/lsacpi.c: Show more info.
 Hide some boring parts 	unless they have unexpected values.

---
 ChangeLog                   |  5 ++++
 grub-core/commands/lsacpi.c | 70 ++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 26702c7..4141f6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-02-01  Vladimir Serbinenko  <phcoder@gmail.com>
 
+	* grub-core/commands/lsacpi.c: Show more info. Hide some boring parts
+	unless they have unexpected values.
+
+2013-02-01  Vladimir Serbinenko  <phcoder@gmail.com>
+
 	* grub-core/bus/usb/usb.c (grub_usb_device_attach): Add missing
 	grub_print_error.
 
diff --git a/grub-core/commands/lsacpi.c b/grub-core/commands/lsacpi.c
index 07c3f0d..1038479 100644
--- a/grub-core/commands/lsacpi.c
+++ b/grub-core/commands/lsacpi.c
@@ -44,7 +44,8 @@ static void
 disp_acpi_table (struct grub_acpi_table_header *t)
 {
   print_field (t->signature);
-  grub_printf ("%4" PRIuGRUB_UINT32_T "B rev=%u OEM=", t->length, t->revision);
+  grub_printf ("%4" PRIuGRUB_UINT32_T "B rev=%u chksum=0x%02x (%s) OEM=", t->length, t->revision, t->checksum,
+	       grub_byte_checksum (t, t->length) == 0 ? "valid" : "invalid");
   print_field (t->oemid);
   print_field (t->oemtable);
   grub_printf ("OEMrev=%08" PRIxGRUB_UINT32_T " ", t->oemrev);
@@ -66,39 +67,81 @@ disp_madt_table (struct grub_acpi_madt *t)
   d = t->entries;
   for (;len > 0; len -= d->len, d = (void *) ((grub_uint8_t *) d + d->len))
     {
-      grub_printf ("  type=%x l=%u ", d->type, d->len);
-
       switch (d->type)
 	{
+	case GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC:
+	  {
+	    struct grub_acpi_madt_entry_lapic *dt = (void *) d;
+	    grub_printf ("  LAPIC ACPI_ID=%02x APIC_ID=%02x Flags=%08x\n",
+			 dt->acpiid, dt->apicid, dt->flags);
+	    if (dt->hdr.len != sizeof (*dt))
+	      grub_printf ("   table size mismatch %d != %d\n", dt->hdr.len, sizeof (*dt));
+	    break;
+	  }
+
+	case GRUB_ACPI_MADT_ENTRY_TYPE_IOAPIC:
+	  {
+	    struct grub_acpi_madt_entry_ioapic *dt = (void *) d;
+	    grub_printf ("  IOAPIC ID=%02x address=%08x GSI=%08x\n",
+			 dt->id, dt->address, dt->global_sys_interrupt);
+	    if (dt->hdr.len != sizeof (*dt))
+	      grub_printf ("   table size mismatch %d != %d\n", dt->hdr.len, sizeof (*dt));
+	    if (dt->pad)
+	      grub_printf ("   non-zero pad: %02x\n", dt->pad);
+	    break;
+	  }
+
 	case GRUB_ACPI_MADT_ENTRY_TYPE_INTERRUPT_OVERRIDE:
 	  {
 	    struct grub_acpi_madt_entry_interrupt_override *dt = (void *) d;
-	    grub_printf ("Int Override bus=%x src=%x GSI=%08x Flags=%04x\n",
+	    grub_printf ("  Int Override bus=%x src=%x GSI=%08x Flags=%04x\n",
 			 dt->bus, dt->source, dt->global_sys_interrupt,
 			 dt->flags);
+	    if (dt->hdr.len != sizeof (*dt))
+	      grub_printf ("   table size mismatch %d != %d\n", dt->hdr.len, sizeof (*dt));
 	  }
 	  break;
+
+	case GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC_NMI:
+	  {
+	    struct grub_acpi_madt_entry_lapic_nmi *dt = (void *) d;
+	    grub_printf ("  LAPIC_NMI ACPI_ID=%02x Flags=%04x lint=%02x\n",
+			 dt->acpiid, dt->flags, dt->lint);
+	    if (dt->hdr.len != sizeof (*dt))
+	      grub_printf ("   table size mismatch %d != %d\n", dt->hdr.len, sizeof (*dt));
+	    break;
+	  }
+
 	case GRUB_ACPI_MADT_ENTRY_TYPE_SAPIC:
 	  {
 	    struct grub_acpi_madt_entry_sapic *dt = (void *) d;
-	    grub_printf ("IOSAPIC Id=%02x GSI=%08x Addr=%016" PRIxGRUB_UINT64_T
+	    grub_printf ("  IOSAPIC Id=%02x GSI=%08x Addr=%016" PRIxGRUB_UINT64_T
 			 "\n",
 			 dt->id, dt->global_sys_interrupt_base,
 			 dt->addr);
+	    if (dt->hdr.len != sizeof (*dt))
+	      grub_printf ("   table size mismatch %d != %d\n", dt->hdr.len, sizeof (*dt));
+	    if (dt->pad)
+	      grub_printf ("   non-zero pad: %02x\n", dt->pad);
+
 	  }
 	  break;
 	case GRUB_ACPI_MADT_ENTRY_TYPE_LSAPIC:
 	  {
 	    struct grub_acpi_madt_entry_lsapic *dt = (void *) d;
-	    grub_printf ("LSAPIC ProcId=%02x ID=%02x EID=%02x Flags=%x",
+	    grub_printf ("  LSAPIC ProcId=%02x ID=%02x EID=%02x Flags=%x",
 			 dt->cpu_id, dt->id, dt->eid, dt->flags);
 	    if (dt->flags & GRUB_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED)
 	      grub_printf (" Enabled\n");
 	    else
 	      grub_printf (" Disabled\n");
 	    if (d->len > sizeof (struct grub_acpi_madt_entry_sapic))
-	      grub_printf ("    UID val=%08x, Str=%s\n", dt->cpu_uid,
+	      grub_printf ("  UID val=%08x, Str=%s\n", dt->cpu_uid,
 			   dt->cpu_uid_str);
+	    if (dt->hdr.len != sizeof (*dt) + grub_strlen ((char *) dt->cpu_uid_str) + 1)
+	      grub_printf ("   table size mismatch %d != %d\n", dt->hdr.len, sizeof (*dt));
+	    if (dt->pad[0] || dt->pad[1] || dt->pad[2])
+	      grub_printf ("   non-zero pad: %02x%02x%02x\n", dt->pad[0], dt->pad[1], dt->pad[2]);
 	  }
 	  break;
 	case GRUB_ACPI_MADT_ENTRY_TYPE_PLATFORM_INT_SOURCE:
@@ -107,17 +150,18 @@ disp_madt_table (struct grub_acpi_madt *t)
 	    static const char * const platint_type[] =
 	      {"Nul", "PMI", "INIT", "CPEI"};
 
-	    grub_printf ("Platform INT flags=%04x type=%02x (%s)"
+	    grub_printf ("  Platform INT flags=%04x type=%02x (%s)"
 			 " ID=%02x EID=%02x\n",
 			 dt->flags, dt->inttype,
 			 (dt->inttype < ARRAY_SIZE (platint_type))
 			 ? platint_type[dt->inttype] : "??", dt->cpu_id,
 			 dt->cpu_eid);
-	    grub_printf ("      IOSAPIC Vec=%02x GSI=%08x source flags=%08x\n",
+	    grub_printf ("  IOSAPIC Vec=%02x GSI=%08x source flags=%08x\n",
 			 dt->sapic_vector, dt->global_sys_int, dt->src_flags);
 	  }
 	  break;
 	default:
+	  grub_printf ("  type=%x l=%u ", d->type, d->len);
 	  grub_printf (" ??\n");
 	}
     }
@@ -182,7 +226,7 @@ static void
 disp_acpi_rsdpv1 (struct grub_acpi_rsdp_v10 *rsdp)
 {
   print_field (rsdp->signature);
-  grub_printf ("chksum:%02x, OEM-ID: ", rsdp->checksum);
+  grub_printf ("chksum:%02x (%s), OEM-ID: ", rsdp->checksum, grub_byte_checksum (rsdp, sizeof (*rsdp)) == 0 ? "valid" : "invalid");
   print_field (rsdp->oemid);
   grub_printf ("rev=%d\n", rsdp->revision);
   grub_printf ("RSDT=%08" PRIxGRUB_UINT32_T "\n", rsdp->rsdt_addr);
@@ -192,8 +236,12 @@ static void
 disp_acpi_rsdpv2 (struct grub_acpi_rsdp_v20 *rsdp)
 {
   disp_acpi_rsdpv1 (&rsdp->rsdpv1);
-  grub_printf ("len=%d XSDT=%016" PRIxGRUB_UINT64_T "\n", rsdp->length,
+  grub_printf ("len=%d chksum=%02x (%s) XSDT=%016" PRIxGRUB_UINT64_T "\n", rsdp->length, rsdp->checksum, grub_byte_checksum (rsdp, rsdp->length) == 0 ? "valid" : "invalid",
 	       rsdp->xsdt_addr);
+  if (rsdp->length != sizeof (*rsdp))
+    grub_printf (" length mismatch %d != %d\n", rsdp->length, sizeof (*rsdp));
+  if (rsdp->reserved[0] || rsdp->reserved[1] || rsdp->reserved[2])
+    grub_printf (" non-zero reserved %02x%02x%02x\n", rsdp->reserved[0], rsdp->reserved[1], rsdp->reserved[2]);
 }
 
 static const struct grub_arg_option options[] = {
-- 
1.8.2.1