ACPICA: Dump table header - suppress output of non-printable characters
authorBob Moore <robert.moore@intel.com>
Wed, 24 Jun 2009 03:38:46 +0000 (11:38 +0800)
committerLen Brown <len.brown@intel.com>
Thu, 27 Aug 2009 14:17:19 +0000 (10:17 -0400)
Function acpi_tb_print_table_header. Some ACPI tables contain
non-printable characters in one of the string fields of the the
header - Signature, OemId, OemTableId, or CompilerId. Invalid
characters are replaced by '?'. ACPICA BZ 788.

http://acpica.org/bugzilla/show_bug.cgi?id=788

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/acpica/tbutils.c

index ef7d2c2d8f0b0067fabf069e547a456afde52fc9..1f15497f00d10dd4319317a0a312ac8be4d2f2f5 100644 (file)
 ACPI_MODULE_NAME("tbutils")
 
 /* Local prototypes */
+static void acpi_tb_fix_string(char *string, acpi_size length);
+
+static void
+acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
+                            struct acpi_table_header *header);
+
 static acpi_physical_address
 acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
 
@@ -159,6 +165,59 @@ u8 acpi_tb_tables_loaded(void)
        return (FALSE);
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_fix_string
+ *
+ * PARAMETERS:  String              - String to be repaired
+ *              Length              - Maximum length
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
+ *              with a question mark '?'.
+ *
+ ******************************************************************************/
+
+static void acpi_tb_fix_string(char *string, acpi_size length)
+{
+
+       while (length && *string) {
+               if (!ACPI_IS_PRINT(*string)) {
+                       *string = '?';
+               }
+               string++;
+               length--;
+       }
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_cleanup_table_header
+ *
+ * PARAMETERS:  out_header          - Where the cleaned header is returned
+ *              Header              - Input ACPI table header
+ *
+ * RETURN:      Returns the cleaned header in out_header
+ *
+ * DESCRIPTION: Copy the table header and ensure that all "string" fields in
+ *              the header consist of printable characters.
+ *
+ ******************************************************************************/
+
+static void
+acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
+                            struct acpi_table_header *header)
+{
+
+       ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header));
+
+       acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE);
+       acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE);
+       acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
+       acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE);
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_tb_print_table_header
@@ -176,6 +235,7 @@ void
 acpi_tb_print_table_header(acpi_physical_address address,
                           struct acpi_table_header *header)
 {
+       struct acpi_table_header local_header;
 
        /*
         * The reason that the Address is cast to a void pointer is so that we
@@ -192,6 +252,11 @@ acpi_tb_print_table_header(acpi_physical_address address,
 
                /* RSDP has no common fields */
 
+               ACPI_MEMCPY(local_header.oem_id,
+                           ACPI_CAST_PTR(struct acpi_table_rsdp,
+                                         header)->oem_id, ACPI_OEM_ID_SIZE);
+               acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
+
                ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
                           ACPI_CAST_PTR (void, address),
                           (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
@@ -200,18 +265,21 @@ acpi_tb_print_table_header(acpi_physical_address address,
                                               header)->length : 20,
                           ACPI_CAST_PTR(struct acpi_table_rsdp,
                                         header)->revision,
-                          ACPI_CAST_PTR(struct acpi_table_rsdp,
-                                        header)->oem_id));
+                          local_header.oem_id));
        } else {
                /* Standard ACPI table with full common header */
 
+               acpi_tb_cleanup_table_header(&local_header, header);
+
                ACPI_INFO((AE_INFO,
                           "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
-                          header->signature, ACPI_CAST_PTR (void, address),
-                          header->length, header->revision, header->oem_id,
-                          header->oem_table_id, header->oem_revision,
-                          header->asl_compiler_id,
-                          header->asl_compiler_revision));
+                          local_header.signature, ACPI_CAST_PTR(void, address),
+                          local_header.length, local_header.revision,
+                          local_header.oem_id, local_header.oem_table_id,
+                          local_header.oem_revision,
+                          local_header.asl_compiler_id,
+                          local_header.asl_compiler_revision));
+
        }
 }