]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ACPICA: Add global pointer for FACS table to simplify FACS access
authorBob Moore <robert.moore@intel.com>
Wed, 12 Nov 2008 07:34:52 +0000 (15:34 +0800)
committerLen Brown <len.brown@intel.com>
Tue, 30 Dec 2008 03:38:37 +0000 (22:38 -0500)
Use a global pointer instead of using AcpiGetTableByIndex for
each FACS access. This simplifies the code for the Global Lock
and the Firmware Waking Vector(s).

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/events/evmisc.c
drivers/acpi/hardware/hwsleep.c
drivers/acpi/tables/tbutils.c
drivers/acpi/utilities/utglobal.c
drivers/acpi/utilities/utxface.c
include/acpi/acglobal.h
include/acpi/actables.h

index 1d5670be729ab3cc13e8d57c639463adce8788dc..82c457fa5a1fda51e1fb0a21c6a7106632372f07 100644 (file)
 #define _COMPONENT          ACPI_EVENTS
 ACPI_MODULE_NAME("evmisc")
 
-/* Pointer to FACS needed for the Global Lock */
-static struct acpi_table_facs *facs = NULL;
-
 /* Local prototypes */
-
 static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
 
 static u32 acpi_ev_global_lock_handler(void *context);
@@ -299,7 +295,7 @@ static u32 acpi_ev_global_lock_handler(void *context)
         * If we don't get it now, it will be marked pending and we will
         * take another interrupt when it becomes free.
         */
-       ACPI_ACQUIRE_GLOBAL_LOCK(facs, acquired);
+       ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
        if (acquired) {
 
                /* Got the lock, now wake all threads waiting for it */
@@ -336,15 +332,8 @@ acpi_status acpi_ev_init_global_lock_handler(void)
 
        ACPI_FUNCTION_TRACE(ev_init_global_lock_handler);
 
-       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);
-       }
+       /* Attempt installation of the global lock handler */
 
-       acpi_gbl_global_lock_present = TRUE;
        status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
                                                  acpi_ev_global_lock_handler,
                                                  NULL);
@@ -361,9 +350,10 @@ acpi_status acpi_ev_init_global_lock_handler(void)
                            "No response from Global Lock hardware, disabling lock"));
 
                acpi_gbl_global_lock_present = FALSE;
-               status = AE_OK;
+               return_ACPI_STATUS(AE_OK);
        }
 
+       acpi_gbl_global_lock_present = TRUE;
        return_ACPI_STATUS(status);
 }
 
@@ -472,7 +462,7 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout)
 
        /* Attempt to acquire the actual hardware lock */
 
-       ACPI_ACQUIRE_GLOBAL_LOCK(facs, acquired);
+       ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
        if (acquired) {
 
                /* We got the lock */
@@ -536,7 +526,7 @@ acpi_status acpi_ev_release_global_lock(void)
 
                /* Allow any thread to release the lock */
 
-               ACPI_RELEASE_GLOBAL_LOCK(facs, pending);
+               ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending);
 
                /*
                 * If the pending bit was set, we must write GBL_RLS to the control
index 6a30c8095ff1644f2b290fa1b07a46b4018a71e9..5ec727ffcbe3bae8006c09e420f37c54bb978d3e 100644 (file)
@@ -63,20 +63,8 @@ ACPI_MODULE_NAME("hwsleep")
 acpi_status
 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
@@ -88,12 +76,12 @@ acpi_set_firmware_waking_vector(u32 physical_address)
 
        /* Set the 32-bit vector */
 
-       facs->firmware_waking_vector = physical_address;
+       acpi_gbl_FACS->firmware_waking_vector = physical_address;
 
        /* Clear the 64-bit vector if it exists */
 
-       if ((facs->length > 32) && (facs->version >= 1)) {
-               facs->xfirmware_waking_vector = 0;
+       if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
+               acpi_gbl_FACS->xfirmware_waking_vector = 0;
        }
 
        return_ACPI_STATUS(AE_OK);
@@ -117,32 +105,19 @@ ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
 acpi_status
 acpi_set_firmware_waking_vector64(u64 physical_address)
 {
-       struct acpi_table_facs *facs;
-       acpi_status status;
-
        ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
 
 
-       /* 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);
-       }
-
        /* Determine if the 64-bit vector actually exists */
 
-       if ((facs->length <= 32) || (facs->version < 1)) {
+       if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
                return_ACPI_STATUS(AE_NOT_EXIST);
        }
 
        /* Clear 32-bit vector, set the 64-bit X_ vector */
 
-       facs->firmware_waking_vector = 0;
-       facs->xfirmware_waking_vector = physical_address;
+       acpi_gbl_FACS->firmware_waking_vector = 0;
+       acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
 
        return_ACPI_STATUS(AE_OK);
 }
index 0cc92ef5236fc261a2167a5a6aa8acb9fbe43d55..50e677711e5b68561af337fbf8b78297bde6bc13 100644 (file)
@@ -111,6 +111,30 @@ acpi_tb_check_xsdt(acpi_physical_address address)
                return AE_OK;
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_initialize_facs
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
+ *              for accessing the Global Lock and Firmware Waking Vector
+ *
+ ******************************************************************************/
+
+acpi_status acpi_tb_initialize_facs(void)
+{
+       acpi_status status;
+
+       status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
+                                        ACPI_CAST_INDIRECT_PTR(struct
+                                                               acpi_table_header,
+                                                               &acpi_gbl_FACS));
+       return status;
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_tb_tables_loaded
index 3dc53114395b8858a59fb7557019f43861ce337e..211d621f42a9a462d978cd5d11d9a9667bf1a9f1 100644 (file)
@@ -771,6 +771,7 @@ acpi_status acpi_ut_init_globals(void)
        acpi_gbl_global_lock_mutex = NULL;
        acpi_gbl_global_lock_acquired = FALSE;
        acpi_gbl_global_lock_handle = 0;
+       acpi_gbl_global_lock_present = FALSE;
 
        /* Miscellaneous variables */
 
index c198a4d40583e7f14fc0e1a545d496c118c98b96..7ca8952eb1b8b86f0c307a8ff5192cb8bd9ec64a 100644 (file)
@@ -45,6 +45,7 @@
 #include <acpi/acevents.h>
 #include <acpi/acnamesp.h>
 #include <acpi/acdebug.h>
+#include <acpi/actables.h>
 
 #define _COMPONENT          ACPI_UTILITIES
 ACPI_MODULE_NAME("utxface")
@@ -147,6 +148,16 @@ acpi_status acpi_enable_subsystem(u32 flags)
                }
        }
 
+       /*
+        * Obtain a permanent mapping for the FACS. This is required for the
+        * Global Lock and the Firmware Waking Vector
+        */
+       status = acpi_tb_initialize_facs();
+       if (ACPI_FAILURE(status)) {
+               ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
+               return_ACPI_STATUS(status);
+       }
+
        /*
         * Install the default op_region handlers. These are installed unless
         * other handlers have already been installed via the
index 15dda46b70d1c1e36c949d9555efc7a805ccf321..77d73a498bfba0f3ae0a795fc0ecbc4f8f15d6e6 100644 (file)
@@ -140,6 +140,7 @@ ACPI_EXTERN u32 acpi_gbl_trace_flags;
  */
 ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list;
 ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT;
+ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
 extern u8 acpi_gbl_permanent_mmap;
 
 /* These addresses are calculated from FADT address values */
index 0cbe1b9ab52249e38adcd12c5fe0c8009d8ebbd9..7ce6e33c7f781ef71f308bd9ebd35ab33c282da7 100644 (file)
@@ -94,6 +94,8 @@ void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
 /*
  * tbutils - table manager utilities
  */
+acpi_status acpi_tb_initialize_facs(void);
+
 u8 acpi_tb_tables_loaded(void);
 
 void