Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[linux-drm-fsl-dcu.git] / drivers / acpi / utilities / utmisc.c
index 33268310c73804be4249cfc258b80f788985c4db..50133fffe42045f7b1155e2edb8edd2ca6900529 100644 (file)
@@ -5,7 +5,7 @@
  ******************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2006, R. Byron Moore
+ * Copyright (C) 2000 - 2007, R. Byron Moore
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #define _COMPONENT          ACPI_UTILITIES
 ACPI_MODULE_NAME("utmisc")
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_validate_exception
+ *
+ * PARAMETERS:  Status       - The acpi_status code to be formatted
+ *
+ * RETURN:      A string containing the exception text. NULL if exception is
+ *              not valid.
+ *
+ * DESCRIPTION: This function validates and translates an ACPI exception into
+ *              an ASCII string.
+ *
+ ******************************************************************************/
+const char *acpi_ut_validate_exception(acpi_status status)
+{
+       acpi_status sub_status;
+       const char *exception = NULL;
+
+       ACPI_FUNCTION_ENTRY();
+
+       /*
+        * Status is composed of two parts, a "type" and an actual code
+        */
+       sub_status = (status & ~AE_CODE_MASK);
+
+       switch (status & AE_CODE_MASK) {
+       case AE_CODE_ENVIRONMENTAL:
+
+               if (sub_status <= AE_CODE_ENV_MAX) {
+                       exception = acpi_gbl_exception_names_env[sub_status];
+               }
+               break;
+
+       case AE_CODE_PROGRAMMER:
+
+               if (sub_status <= AE_CODE_PGM_MAX) {
+                       exception =
+                           acpi_gbl_exception_names_pgm[sub_status - 1];
+               }
+               break;
+
+       case AE_CODE_ACPI_TABLES:
+
+               if (sub_status <= AE_CODE_TBL_MAX) {
+                       exception =
+                           acpi_gbl_exception_names_tbl[sub_status - 1];
+               }
+               break;
+
+       case AE_CODE_AML:
+
+               if (sub_status <= AE_CODE_AML_MAX) {
+                       exception =
+                           acpi_gbl_exception_names_aml[sub_status - 1];
+               }
+               break;
+
+       case AE_CODE_CONTROL:
+
+               if (sub_status <= AE_CODE_CTRL_MAX) {
+                       exception =
+                           acpi_gbl_exception_names_ctrl[sub_status - 1];
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       return (ACPI_CAST_PTR(const char, exception));
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ut_is_aml_table
@@ -62,14 +134,15 @@ ACPI_MODULE_NAME("utmisc")
  *              data tables that do not contain AML code.
  *
  ******************************************************************************/
+
 u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
 {
 
-       /* Ignore tables that contain AML */
+       /* These are the only tables that contain executable AML */
 
-       if (ACPI_COMPARE_NAME(table->signature, DSDT_SIG) ||
-           ACPI_COMPARE_NAME(table->signature, PSDT_SIG) ||
-           ACPI_COMPARE_NAME(table->signature, SSDT_SIG)) {
+       if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) ||
+           ACPI_COMPARE_NAME(table->signature, ACPI_SIG_PSDT) ||
+           ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) {
                return (TRUE);
        }
 
@@ -418,11 +491,16 @@ u32 acpi_ut_dword_byte_swap(u32 value)
 void acpi_ut_set_integer_width(u8 revision)
 {
 
-       if (revision <= 1) {
+       if (revision < 2) {
+
+               /* 32-bit case */
+
                acpi_gbl_integer_bit_width = 32;
                acpi_gbl_integer_nybble_width = 8;
                acpi_gbl_integer_byte_width = 4;
        } else {
+               /* 64-bit case (ACPI 2.0+) */
+
                acpi_gbl_integer_bit_width = 64;
                acpi_gbl_integer_nybble_width = 16;
                acpi_gbl_integer_byte_width = 8;
@@ -502,6 +580,7 @@ acpi_ut_display_init_pathname(u8 type,
  * FUNCTION:    acpi_ut_valid_acpi_char
  *
  * PARAMETERS:  Char            - The character to be examined
+ *              Position        - Byte position (0-3)
  *
  * RETURN:      TRUE if the character is valid, FALSE otherwise
  *
@@ -576,26 +655,25 @@ u8 acpi_ut_valid_acpi_name(u32 name)
  *
  ******************************************************************************/
 
-acpi_name acpi_ut_repair_name(acpi_name name)
+acpi_name acpi_ut_repair_name(char *name)
 {
-       char *name_ptr = ACPI_CAST_PTR(char, &name);
-       char new_name[ACPI_NAME_SIZE];
        acpi_native_uint i;
+       char new_name[ACPI_NAME_SIZE];
 
        for (i = 0; i < ACPI_NAME_SIZE; i++) {
-               new_name[i] = name_ptr[i];
+               new_name[i] = name[i];
 
                /*
                 * Replace a bad character with something printable, yet technically
                 * still invalid. This prevents any collisions with existing "good"
                 * names in the namespace.
                 */
-               if (!acpi_ut_valid_acpi_char(name_ptr[i], i)) {
+               if (!acpi_ut_valid_acpi_char(name[i], i)) {
                        new_name[i] = '*';
                }
        }
 
-       return (*ACPI_CAST_PTR(u32, new_name));
+       return (*(u32 *) new_name);
 }
 
 /*******************************************************************************
@@ -609,7 +687,9 @@ acpi_name acpi_ut_repair_name(acpi_name name)
  *
  * RETURN:      Status and Converted value
  *
- * DESCRIPTION: Convert a string into an unsigned value.
+ * DESCRIPTION: Convert a string into an unsigned value. Performs either a
+ *              32-bit or 64-bit conversion, depending on the current mode
+ *              of the interpreter.
  *              NOTE: Does not support Octal strings, not needed.
  *
  ******************************************************************************/
@@ -627,7 +707,7 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
        u8 sign_of0x = 0;
        u8 term = 0;
 
-       ACPI_FUNCTION_TRACE(ut_stroul64);
+       ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
 
        switch (base) {
        case ACPI_ANY_BASE:
@@ -675,11 +755,13 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
                }
        }
 
+       /*
+        * Perform a 32-bit or 64-bit conversion, depending upon the current
+        * execution mode of the interpreter
+        */
        dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
 
-       /* At least one character in the string here */
-
-       /* Main loop: convert the string to a 64-bit integer */
+       /* Main loop: convert the string to a 32- or 64-bit integer */
 
        while (*string) {
                if (ACPI_IS_DIGIT(*string)) {
@@ -754,6 +836,9 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
 
       all_done:
 
+       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
+                         ACPI_FORMAT_UINT64(return_value)));
+
        *ret_integer = return_value;
        return_ACPI_STATUS(AE_OK);
 
@@ -983,9 +1068,13 @@ acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
 {
        va_list args;
 
-       acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
+       /*
+        * Removed module_name, line_number, and acpica version, not needed
+        * for info output
+        */
+       acpi_os_printf("ACPI: ");
 
        va_start(args, format);
        acpi_os_vprintf(format, args);
-       acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
+       acpi_os_printf("\n");
 }