linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / acpi / tables / tbutils.c
index 209a401..bc57159 100644 (file)
@@ -71,7 +71,7 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
 {
        struct acpi_table_desc *table_desc;
 
-       ACPI_FUNCTION_TRACE(tb_is_table_installed);
+       ACPI_FUNCTION_TRACE("tb_is_table_installed");
 
        /* Get the list descriptor and first table descriptor */
 
@@ -96,11 +96,10 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
                    (!ACPI_MEMCMP
                     (table_desc->pointer, new_table_desc->pointer,
                      new_table_desc->pointer->length))) {
-
                        /* Match: this table is already installed */
 
                        ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
-                                         "Table [%4.4s] already installed: Rev %X OemTableId [%8.8s]\n",
+                                         "Table [%4.4s] already installed: Rev %X oem_table_id [%8.8s]\n",
                                          new_table_desc->pointer->signature,
                                          new_table_desc->pointer->revision,
                                          new_table_desc->pointer->
@@ -160,8 +159,12 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
 
        ACPI_MOVE_32_TO_32(&signature, table_header->signature);
        if (!acpi_ut_valid_acpi_name(signature)) {
-               ACPI_ERROR((AE_INFO, "Invalid table signature 0x%8.8X",
-                           signature));
+               ACPI_ERROR((AE_INFO,
+                           "Table signature at %p [%p] has invalid characters",
+                           table_header, &signature));
+
+               ACPI_WARNING((AE_INFO, "Invalid table signature found: [%4.4s]",
+                             ACPI_CAST_PTR(char, &signature)));
 
                ACPI_DUMP_BUFFER(table_header,
                                 sizeof(struct acpi_table_header));
@@ -172,9 +175,12 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
 
        if (table_header->length < sizeof(struct acpi_table_header)) {
                ACPI_ERROR((AE_INFO,
-                           "Invalid length 0x%X in table with signature %4.4s",
-                           (u32) table_header->length,
-                           ACPI_CAST_PTR(char, &signature)));
+                           "Invalid length in table header %p name %4.4s",
+                           table_header, (char *)&signature));
+
+               ACPI_WARNING((AE_INFO,
+                             "Invalid table header length (0x%X) found",
+                             (u32) table_header->length));
 
                ACPI_DUMP_BUFFER(table_header,
                                 sizeof(struct acpi_table_header));
@@ -186,119 +192,72 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_tb_sum_table
- *
- * PARAMETERS:  Buffer              - Buffer to sum
- *              Length              - Size of the buffer
- *
- * RETURN:      8 bit sum of buffer
- *
- * DESCRIPTION: Computes an 8 bit sum of the buffer(length) and returns it.
- *
- ******************************************************************************/
-
-u8 acpi_tb_sum_table(void *buffer, u32 length)
-{
-       acpi_native_uint i;
-       u8 sum = 0;
-
-       if (!buffer || !length) {
-               return (0);
-       }
-
-       for (i = 0; i < length; i++) {
-               sum = (u8) (sum + ((u8 *) buffer)[i]);
-       }
-       return (sum);
-}
-
-/*******************************************************************************
- *
- * FUNCTION:    acpi_tb_generate_checksum
+ * FUNCTION:    acpi_tb_verify_table_checksum
  *
- * PARAMETERS:  Table               - Pointer to a valid ACPI table (with a
- *                                    standard ACPI header)
+ * PARAMETERS:  *table_header           - ACPI table to verify
  *
- * RETURN:      8 bit checksum of buffer
+ * RETURN:      8 bit checksum of table
  *
- * DESCRIPTION: Computes an 8 bit checksum of the table.
+ * DESCRIPTION: Does an 8 bit checksum of table and returns status.  A correct
+ *              table should have a checksum of 0.
  *
  ******************************************************************************/
 
-u8 acpi_tb_generate_checksum(struct acpi_table_header * table)
+acpi_status
+acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
 {
        u8 checksum;
+       acpi_status status = AE_OK;
 
-       /* Sum the entire table as-is */
-
-       checksum = acpi_tb_sum_table(table, table->length);
+       ACPI_FUNCTION_TRACE("tb_verify_table_checksum");
 
-       /* Subtract off the existing checksum value in the table */
+       /* Compute the checksum on the table */
 
-       checksum = (u8) (checksum - table->checksum);
+       checksum =
+           acpi_tb_generate_checksum(table_header, table_header->length);
 
-       /* Compute the final checksum */
+       /* Return the appropriate exception */
 
-       checksum = (u8) (0 - checksum);
-       return (checksum);
-}
+       if (checksum) {
+               ACPI_WARNING((AE_INFO,
+                             "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)",
+                             table_header->signature,
+                             (u32) table_header->checksum, (u32) checksum));
 
-/*******************************************************************************
- *
- * FUNCTION:    acpi_tb_set_checksum
- *
- * PARAMETERS:  Table               - Pointer to a valid ACPI table (with a
- *                                    standard ACPI header)
- *
- * RETURN:      None. Sets the table checksum field
- *
- * DESCRIPTION: Computes an 8 bit checksum of the table and inserts the
- *              checksum into the table header.
- *
- ******************************************************************************/
-
-void acpi_tb_set_checksum(struct acpi_table_header *table)
-{
-
-       table->checksum = acpi_tb_generate_checksum(table);
+               status = AE_BAD_CHECKSUM;
+       }
+       return_ACPI_STATUS(status);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_tb_verify_table_checksum
+ * FUNCTION:    acpi_tb_generate_checksum
  *
- * PARAMETERS:  *table_header           - ACPI table to verify
+ * PARAMETERS:  Buffer              - Buffer to checksum
+ *              Length              - Size of the buffer
  *
- * RETURN:      8 bit checksum of table
+ * RETURN:      8 bit checksum of buffer
  *
- * DESCRIPTION: Generates an 8 bit checksum of table and returns and compares
- *              it to the existing checksum value.
+ * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it.
  *
  ******************************************************************************/
 
-acpi_status
-acpi_tb_verify_table_checksum(struct acpi_table_header *table_header)
+u8 acpi_tb_generate_checksum(void *buffer, u32 length)
 {
-       u8 checksum;
-
-       ACPI_FUNCTION_TRACE(tb_verify_table_checksum);
-
-       /* Compute the checksum on the table */
+       u8 *end_buffer;
+       u8 *rover;
+       u8 sum = 0;
 
-       checksum = acpi_tb_generate_checksum(table_header);
+       if (buffer && length) {
+               /*  Buffer and Length are valid   */
 
-       /* Checksum ok? */
+               end_buffer = ACPI_ADD_PTR(u8, buffer, length);
 
-       if (checksum == table_header->checksum) {
-               return_ACPI_STATUS(AE_OK);
+               for (rover = buffer; rover < end_buffer; rover++) {
+                       sum = (u8) (sum + *rover);
+               }
        }
-
-       ACPI_WARNING((AE_INFO,
-                     "Incorrect checksum in table [%4.4s] - is %2.2X, should be %2.2X",
-                     table_header->signature, table_header->checksum,
-                     checksum));
-
-       return_ACPI_STATUS(AE_BAD_CHECKSUM);
+       return (sum);
 }
 
 #ifdef ACPI_OBSOLETE_FUNCTIONS
@@ -317,12 +276,12 @@ acpi_tb_verify_table_checksum(struct acpi_table_header *table_header)
 
 acpi_status
 acpi_tb_handle_to_object(u16 table_id,
-                        struct acpi_table_desc **return_table_desc)
+                        struct acpi_table_desc ** return_table_desc)
 {
        u32 i;
        struct acpi_table_desc *table_desc;
 
-       ACPI_FUNCTION_NAME(tb_handle_to_object);
+       ACPI_FUNCTION_NAME("tb_handle_to_object");
 
        for (i = 0; i < ACPI_TABLE_MAX; i++) {
                table_desc = acpi_gbl_table_lists[i].next;
@@ -336,7 +295,7 @@ acpi_tb_handle_to_object(u16 table_id,
                }
        }
 
-       ACPI_ERROR((AE_INFO, "TableId=%X does not exist", table_id));
+       ACPI_ERROR((AE_INFO, "table_id=%X does not exist", table_id));
        return (AE_BAD_PARAMETER);
 }
 #endif