Blame SOURCES/0148-grub-core-commands-lsacpi.c-Show-more-info.-Hide-som.patch

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