ACPICA: Add global pointer for FACS table to simplify FACS access
[deliverable/linux.git] / drivers / acpi / hardware / hwsleep.c
index dba3cfbe8cba9e3235970e7b972e7f54da24c4af..5ec727ffcbe3bae8006c09e420f37c54bb978d3e 100644 (file)
@@ -52,44 +52,36 @@ ACPI_MODULE_NAME("hwsleep")
  *
  * FUNCTION:    acpi_set_firmware_waking_vector
  *
- * PARAMETERS:  physical_address    - Physical address of ACPI real mode
+ * PARAMETERS:  physical_address    - 32-bit physical address of ACPI real mode
  *                                    entry point.
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
+ * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
  *
  ******************************************************************************/
 acpi_status
-acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
+acpi_set_firmware_waking_vector(u32 physical_address)
 {
-       struct acpi_table_facs *facs;
-       acpi_status status;
-
        ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
 
-       /* Get the FACS */
 
-       status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
-                                        ACPI_CAST_INDIRECT_PTR(struct
-                                                               acpi_table_header,
-                                                               &facs));
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
-       }
+       /*
+        * According to the ACPI specification 2.0c and later, the 64-bit
+        * waking vector should be cleared and the 32-bit waking vector should
+        * be used, unless we want the wake-up code to be called by the BIOS in
+        * Protected Mode.  Some systems (for example HP dv5-1004nr) are known
+        * to fail to resume if the 64-bit vector is used.
+        */
 
-       /* Set the vector */
+       /* Set the 32-bit vector */
 
-       if ((facs->length < 32) || (!(facs->xfirmware_waking_vector))) {
-               /*
-                * ACPI 1.0 FACS or short table or optional X_ field is zero
-                */
-               facs->firmware_waking_vector = (u32) physical_address;
-       } else {
-               /*
-                * ACPI 2.0 FACS with valid X_ field
-                */
-               facs->xfirmware_waking_vector = physical_address;
+       acpi_gbl_FACS->firmware_waking_vector = physical_address;
+
+       /* Clear the 64-bit vector if it exists */
+
+       if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
+               acpi_gbl_FACS->xfirmware_waking_vector = 0;
        }
 
        return_ACPI_STATUS(AE_OK);
@@ -99,61 +91,39 @@ ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_get_firmware_waking_vector
+ * FUNCTION:    acpi_set_firmware_waking_vector64
  *
- * PARAMETERS:  *physical_address   - Where the contents of
- *                                    the firmware_waking_vector field of
- *                                    the FACS will be returned.
+ * PARAMETERS:  physical_address    - 64-bit physical address of ACPI protected
+ *                                    mode entry point.
  *
- * RETURN:      Status, vector
+ * RETURN:      Status
  *
- * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
+ * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
+ *              it exists in the table.
  *
  ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
 acpi_status
-acpi_get_firmware_waking_vector(acpi_physical_address * physical_address)
+acpi_set_firmware_waking_vector64(u64 physical_address)
 {
-       struct acpi_table_facs *facs;
-       acpi_status status;
-
-       ACPI_FUNCTION_TRACE(acpi_get_firmware_waking_vector);
+       ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
 
-       if (!physical_address) {
-               return_ACPI_STATUS(AE_BAD_PARAMETER);
-       }
 
-       /* Get the FACS */
+       /* Determine if the 64-bit vector actually exists */
 
-       status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
-                                        ACPI_CAST_INDIRECT_PTR(struct
-                                                               acpi_table_header,
-                                                               &facs));
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
+       if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
+               return_ACPI_STATUS(AE_NOT_EXIST);
        }
 
-       /* Get the vector */
+       /* Clear 32-bit vector, set the 64-bit X_ vector */
 
-       if ((facs->length < 32) || (!(facs->xfirmware_waking_vector))) {
-               /*
-                * ACPI 1.0 FACS or short table or optional X_ field is zero
-                */
-               *physical_address =
-                   (acpi_physical_address) facs->firmware_waking_vector;
-       } else {
-               /*
-                * ACPI 2.0 FACS with valid X_ field
-                */
-               *physical_address =
-                   (acpi_physical_address) facs->xfirmware_waking_vector;
-       }
+       acpi_gbl_FACS->firmware_waking_vector = 0;
+       acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
 
        return_ACPI_STATUS(AE_OK);
 }
 
-ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector)
-#endif
+ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_enter_sleep_state_prep
@@ -627,6 +597,13 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
        }
        /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
 
+       /*
+        * Some BIOSes assume that WAK_STS will be cleared on resume and use
+        * it to determine whether the system is rebooting or resuming. Clear
+        * it for compatibility.
+        */
+       acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
+
        acpi_gbl_system_awake_and_running = TRUE;
 
        /* Enable power button */
This page took 0.026587 seconds and 5 git commands to generate.