195b482a8SLen Brown /****************************************************************************** 295b482a8SLen Brown * 395b482a8SLen Brown * Module Name: utxface - External interfaces for "global" ACPI functions 495b482a8SLen Brown * 595b482a8SLen Brown *****************************************************************************/ 695b482a8SLen Brown 795b482a8SLen Brown /* 8b4e104eaSBob Moore * Copyright (C) 2000 - 2011, Intel Corp. 995b482a8SLen Brown * All rights reserved. 1095b482a8SLen Brown * 1195b482a8SLen Brown * Redistribution and use in source and binary forms, with or without 1295b482a8SLen Brown * modification, are permitted provided that the following conditions 1395b482a8SLen Brown * are met: 1495b482a8SLen Brown * 1. Redistributions of source code must retain the above copyright 1595b482a8SLen Brown * notice, this list of conditions, and the following disclaimer, 1695b482a8SLen Brown * without modification. 1795b482a8SLen Brown * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1895b482a8SLen Brown * substantially similar to the "NO WARRANTY" disclaimer below 1995b482a8SLen Brown * ("Disclaimer") and any redistribution must be conditioned upon 2095b482a8SLen Brown * including a substantially similar Disclaimer requirement for further 2195b482a8SLen Brown * binary redistribution. 2295b482a8SLen Brown * 3. Neither the names of the above-listed copyright holders nor the names 2395b482a8SLen Brown * of any contributors may be used to endorse or promote products derived 2495b482a8SLen Brown * from this software without specific prior written permission. 2595b482a8SLen Brown * 2695b482a8SLen Brown * Alternatively, this software may be distributed under the terms of the 2795b482a8SLen Brown * GNU General Public License ("GPL") version 2 as published by the Free 2895b482a8SLen Brown * Software Foundation. 2995b482a8SLen Brown * 3095b482a8SLen Brown * NO WARRANTY 3195b482a8SLen Brown * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3295b482a8SLen Brown * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3395b482a8SLen Brown * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3495b482a8SLen Brown * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3595b482a8SLen Brown * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3695b482a8SLen Brown * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3795b482a8SLen Brown * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3895b482a8SLen Brown * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3995b482a8SLen Brown * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4095b482a8SLen Brown * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4195b482a8SLen Brown * POSSIBILITY OF SUCH DAMAGES. 4295b482a8SLen Brown */ 4395b482a8SLen Brown 4495b482a8SLen Brown #include <acpi/acpi.h> 45e2f7a777SLen Brown #include "accommon.h" 46e2f7a777SLen Brown #include "acevents.h" 47e2f7a777SLen Brown #include "acnamesp.h" 48e2f7a777SLen Brown #include "acdebug.h" 49e2f7a777SLen Brown #include "actables.h" 5095b482a8SLen Brown 5195b482a8SLen Brown #define _COMPONENT ACPI_UTILITIES 5295b482a8SLen Brown ACPI_MODULE_NAME("utxface") 5395b482a8SLen Brown 5495b482a8SLen Brown #ifndef ACPI_ASL_COMPILER 5595b482a8SLen Brown /******************************************************************************* 5695b482a8SLen Brown * 5795b482a8SLen Brown * FUNCTION: acpi_initialize_subsystem 5895b482a8SLen Brown * 5995b482a8SLen Brown * PARAMETERS: None 6095b482a8SLen Brown * 6195b482a8SLen Brown * RETURN: Status 6295b482a8SLen Brown * 6395b482a8SLen Brown * DESCRIPTION: Initializes all global variables. This is the first function 6495b482a8SLen Brown * called, so any early initialization belongs here. 6595b482a8SLen Brown * 6695b482a8SLen Brown ******************************************************************************/ 6795b482a8SLen Brown acpi_status __init acpi_initialize_subsystem(void) 6895b482a8SLen Brown { 6995b482a8SLen Brown acpi_status status; 7095b482a8SLen Brown 7195b482a8SLen Brown ACPI_FUNCTION_TRACE(acpi_initialize_subsystem); 7295b482a8SLen Brown 7395b482a8SLen Brown acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE; 7495b482a8SLen Brown ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace()); 7595b482a8SLen Brown 7695b482a8SLen Brown /* Initialize the OS-Dependent layer */ 7795b482a8SLen Brown 7895b482a8SLen Brown status = acpi_os_initialize(); 7995b482a8SLen Brown if (ACPI_FAILURE(status)) { 8095b482a8SLen Brown ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization")); 8195b482a8SLen Brown return_ACPI_STATUS(status); 8295b482a8SLen Brown } 8395b482a8SLen Brown 8495b482a8SLen Brown /* Initialize all globals used by the subsystem */ 8595b482a8SLen Brown 8695b482a8SLen Brown status = acpi_ut_init_globals(); 8795b482a8SLen Brown if (ACPI_FAILURE(status)) { 8895b482a8SLen Brown ACPI_EXCEPTION((AE_INFO, status, 8995b482a8SLen Brown "During initialization of globals")); 9095b482a8SLen Brown return_ACPI_STATUS(status); 9195b482a8SLen Brown } 9295b482a8SLen Brown 9395b482a8SLen Brown /* Create the default mutex objects */ 9495b482a8SLen Brown 9595b482a8SLen Brown status = acpi_ut_mutex_initialize(); 9695b482a8SLen Brown if (ACPI_FAILURE(status)) { 9795b482a8SLen Brown ACPI_EXCEPTION((AE_INFO, status, 9895b482a8SLen Brown "During Global Mutex creation")); 9995b482a8SLen Brown return_ACPI_STATUS(status); 10095b482a8SLen Brown } 10195b482a8SLen Brown 10295b482a8SLen Brown /* 10395b482a8SLen Brown * Initialize the namespace manager and 10495b482a8SLen Brown * the root of the namespace tree 10595b482a8SLen Brown */ 10695b482a8SLen Brown status = acpi_ns_root_initialize(); 10795b482a8SLen Brown if (ACPI_FAILURE(status)) { 10895b482a8SLen Brown ACPI_EXCEPTION((AE_INFO, status, 10995b482a8SLen Brown "During Namespace initialization")); 11095b482a8SLen Brown return_ACPI_STATUS(status); 11195b482a8SLen Brown } 11295b482a8SLen Brown 113b0ed7a91SLin Ming /* Initialize the global OSI interfaces list with the static names */ 114b0ed7a91SLin Ming 115b0ed7a91SLin Ming status = acpi_ut_initialize_interfaces(); 116b0ed7a91SLin Ming if (ACPI_FAILURE(status)) { 117b0ed7a91SLin Ming ACPI_EXCEPTION((AE_INFO, status, 118b0ed7a91SLin Ming "During OSI interfaces initialization")); 119b0ed7a91SLin Ming return_ACPI_STATUS(status); 120b0ed7a91SLin Ming } 121b0ed7a91SLin Ming 12295b482a8SLen Brown /* If configured, initialize the AML debugger */ 12395b482a8SLen Brown 12495b482a8SLen Brown ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); 12595b482a8SLen Brown return_ACPI_STATUS(status); 12695b482a8SLen Brown } 12795b482a8SLen Brown 12895b482a8SLen Brown /******************************************************************************* 12995b482a8SLen Brown * 13095b482a8SLen Brown * FUNCTION: acpi_enable_subsystem 13195b482a8SLen Brown * 13295b482a8SLen Brown * PARAMETERS: Flags - Init/enable Options 13395b482a8SLen Brown * 13495b482a8SLen Brown * RETURN: Status 13595b482a8SLen Brown * 13695b482a8SLen Brown * DESCRIPTION: Completes the subsystem initialization including hardware. 13795b482a8SLen Brown * Puts system into ACPI mode if it isn't already. 13895b482a8SLen Brown * 13995b482a8SLen Brown ******************************************************************************/ 14095b482a8SLen Brown acpi_status acpi_enable_subsystem(u32 flags) 14195b482a8SLen Brown { 14295b482a8SLen Brown acpi_status status = AE_OK; 14395b482a8SLen Brown 14495b482a8SLen Brown ACPI_FUNCTION_TRACE(acpi_enable_subsystem); 14595b482a8SLen Brown 14695b482a8SLen Brown /* Enable ACPI mode */ 14795b482a8SLen Brown 14895b482a8SLen Brown if (!(flags & ACPI_NO_ACPI_ENABLE)) { 14995b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 15095b482a8SLen Brown "[Init] Going into ACPI mode\n")); 15195b482a8SLen Brown 15295b482a8SLen Brown acpi_gbl_original_mode = acpi_hw_get_mode(); 15395b482a8SLen Brown 15495b482a8SLen Brown status = acpi_enable(); 15595b482a8SLen Brown if (ACPI_FAILURE(status)) { 15695b482a8SLen Brown ACPI_WARNING((AE_INFO, "AcpiEnable failed")); 15795b482a8SLen Brown return_ACPI_STATUS(status); 15895b482a8SLen Brown } 15995b482a8SLen Brown } 16095b482a8SLen Brown 16195b482a8SLen Brown /* 16295b482a8SLen Brown * Obtain a permanent mapping for the FACS. This is required for the 16395b482a8SLen Brown * Global Lock and the Firmware Waking Vector 16495b482a8SLen Brown */ 16595b482a8SLen Brown status = acpi_tb_initialize_facs(); 16695b482a8SLen Brown if (ACPI_FAILURE(status)) { 16795b482a8SLen Brown ACPI_WARNING((AE_INFO, "Could not map the FACS table")); 16895b482a8SLen Brown return_ACPI_STATUS(status); 16995b482a8SLen Brown } 17095b482a8SLen Brown 17195b482a8SLen Brown /* 17295b482a8SLen Brown * Install the default op_region handlers. These are installed unless 17395b482a8SLen Brown * other handlers have already been installed via the 17495b482a8SLen Brown * install_address_space_handler interface. 17595b482a8SLen Brown */ 17695b482a8SLen Brown if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 17795b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 17895b482a8SLen Brown "[Init] Installing default address space handlers\n")); 17995b482a8SLen Brown 18095b482a8SLen Brown status = acpi_ev_install_region_handlers(); 18195b482a8SLen Brown if (ACPI_FAILURE(status)) { 18295b482a8SLen Brown return_ACPI_STATUS(status); 18395b482a8SLen Brown } 18495b482a8SLen Brown } 18595b482a8SLen Brown 18695b482a8SLen Brown /* 18795b482a8SLen Brown * Initialize ACPI Event handling (Fixed and General Purpose) 18895b482a8SLen Brown * 18995b482a8SLen Brown * Note1: We must have the hardware and events initialized before we can 19095b482a8SLen Brown * execute any control methods safely. Any control method can require 19195b482a8SLen Brown * ACPI hardware support, so the hardware must be fully initialized before 19295b482a8SLen Brown * any method execution! 19395b482a8SLen Brown * 19495b482a8SLen Brown * Note2: Fixed events are initialized and enabled here. GPEs are 19595b482a8SLen Brown * initialized, but cannot be enabled until after the hardware is 19695b482a8SLen Brown * completely initialized (SCI and global_lock activated) 19795b482a8SLen Brown */ 19895b482a8SLen Brown if (!(flags & ACPI_NO_EVENT_INIT)) { 19995b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 20095b482a8SLen Brown "[Init] Initializing ACPI events\n")); 20195b482a8SLen Brown 20295b482a8SLen Brown status = acpi_ev_initialize_events(); 20395b482a8SLen Brown if (ACPI_FAILURE(status)) { 20495b482a8SLen Brown return_ACPI_STATUS(status); 20595b482a8SLen Brown } 20695b482a8SLen Brown } 20795b482a8SLen Brown 20895b482a8SLen Brown /* 20995b482a8SLen Brown * Install the SCI handler and Global Lock handler. This completes the 21095b482a8SLen Brown * hardware initialization. 21195b482a8SLen Brown */ 21295b482a8SLen Brown if (!(flags & ACPI_NO_HANDLER_INIT)) { 21395b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 21495b482a8SLen Brown "[Init] Installing SCI/GL handlers\n")); 21595b482a8SLen Brown 21695b482a8SLen Brown status = acpi_ev_install_xrupt_handlers(); 21795b482a8SLen Brown if (ACPI_FAILURE(status)) { 21895b482a8SLen Brown return_ACPI_STATUS(status); 21995b482a8SLen Brown } 22095b482a8SLen Brown } 22195b482a8SLen Brown 22295b482a8SLen Brown return_ACPI_STATUS(status); 22395b482a8SLen Brown } 22495b482a8SLen Brown 22595b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_enable_subsystem) 22695b482a8SLen Brown 22795b482a8SLen Brown /******************************************************************************* 22895b482a8SLen Brown * 22995b482a8SLen Brown * FUNCTION: acpi_initialize_objects 23095b482a8SLen Brown * 23195b482a8SLen Brown * PARAMETERS: Flags - Init/enable Options 23295b482a8SLen Brown * 23395b482a8SLen Brown * RETURN: Status 23495b482a8SLen Brown * 23595b482a8SLen Brown * DESCRIPTION: Completes namespace initialization by initializing device 23695b482a8SLen Brown * objects and executing AML code for Regions, buffers, etc. 23795b482a8SLen Brown * 23895b482a8SLen Brown ******************************************************************************/ 23995b482a8SLen Brown acpi_status acpi_initialize_objects(u32 flags) 24095b482a8SLen Brown { 24195b482a8SLen Brown acpi_status status = AE_OK; 24295b482a8SLen Brown 24395b482a8SLen Brown ACPI_FUNCTION_TRACE(acpi_initialize_objects); 24495b482a8SLen Brown 24595b482a8SLen Brown /* 24695b482a8SLen Brown * Run all _REG methods 24795b482a8SLen Brown * 24895b482a8SLen Brown * Note: Any objects accessed by the _REG methods will be automatically 24995b482a8SLen Brown * initialized, even if they contain executable AML (see the call to 25095b482a8SLen Brown * acpi_ns_initialize_objects below). 25195b482a8SLen Brown */ 25295b482a8SLen Brown if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 25395b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 25495b482a8SLen Brown "[Init] Executing _REG OpRegion methods\n")); 25595b482a8SLen Brown 25695b482a8SLen Brown status = acpi_ev_initialize_op_regions(); 25795b482a8SLen Brown if (ACPI_FAILURE(status)) { 25895b482a8SLen Brown return_ACPI_STATUS(status); 25995b482a8SLen Brown } 26095b482a8SLen Brown } 26195b482a8SLen Brown 26295b482a8SLen Brown /* 2637f0c826aSLin Ming * Execute any module-level code that was detected during the table load 2647f0c826aSLin Ming * phase. Although illegal since ACPI 2.0, there are many machines that 2657f0c826aSLin Ming * contain this type of code. Each block of detected executable AML code 2667f0c826aSLin Ming * outside of any control method is wrapped with a temporary control 2677f0c826aSLin Ming * method object and placed on a global list. The methods on this list 2687f0c826aSLin Ming * are executed below. 2697f0c826aSLin Ming */ 2707f0c826aSLin Ming acpi_ns_exec_module_code_list(); 2717f0c826aSLin Ming 2727f0c826aSLin Ming /* 27395b482a8SLen Brown * Initialize the objects that remain uninitialized. This runs the 27495b482a8SLen Brown * executable AML that may be part of the declaration of these objects: 27595b482a8SLen Brown * operation_regions, buffer_fields, Buffers, and Packages. 27695b482a8SLen Brown */ 27795b482a8SLen Brown if (!(flags & ACPI_NO_OBJECT_INIT)) { 27895b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 27995b482a8SLen Brown "[Init] Completing Initialization of ACPI Objects\n")); 28095b482a8SLen Brown 28195b482a8SLen Brown status = acpi_ns_initialize_objects(); 28295b482a8SLen Brown if (ACPI_FAILURE(status)) { 28395b482a8SLen Brown return_ACPI_STATUS(status); 28495b482a8SLen Brown } 28595b482a8SLen Brown } 28695b482a8SLen Brown 28795b482a8SLen Brown /* 28895b482a8SLen Brown * Initialize all device objects in the namespace. This runs the device 28995b482a8SLen Brown * _STA and _INI methods. 29095b482a8SLen Brown */ 29195b482a8SLen Brown if (!(flags & ACPI_NO_DEVICE_INIT)) { 29295b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 29395b482a8SLen Brown "[Init] Initializing ACPI Devices\n")); 29495b482a8SLen Brown 29595b482a8SLen Brown status = acpi_ns_initialize_devices(); 29695b482a8SLen Brown if (ACPI_FAILURE(status)) { 29795b482a8SLen Brown return_ACPI_STATUS(status); 29895b482a8SLen Brown } 29995b482a8SLen Brown } 30095b482a8SLen Brown 30195b482a8SLen Brown /* 30295b482a8SLen Brown * Empty the caches (delete the cached objects) on the assumption that 30395b482a8SLen Brown * the table load filled them up more than they will be at runtime -- 30495b482a8SLen Brown * thus wasting non-paged memory. 30595b482a8SLen Brown */ 30695b482a8SLen Brown status = acpi_purge_cached_objects(); 30795b482a8SLen Brown 30895b482a8SLen Brown acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; 30995b482a8SLen Brown return_ACPI_STATUS(status); 31095b482a8SLen Brown } 31195b482a8SLen Brown 31295b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_initialize_objects) 31395b482a8SLen Brown 31495b482a8SLen Brown #endif 31595b482a8SLen Brown /******************************************************************************* 31695b482a8SLen Brown * 31795b482a8SLen Brown * FUNCTION: acpi_terminate 31895b482a8SLen Brown * 31995b482a8SLen Brown * PARAMETERS: None 32095b482a8SLen Brown * 32195b482a8SLen Brown * RETURN: Status 32295b482a8SLen Brown * 3232f977b36SBob Moore * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. 32495b482a8SLen Brown * 32595b482a8SLen Brown ******************************************************************************/ 32695b482a8SLen Brown acpi_status acpi_terminate(void) 32795b482a8SLen Brown { 32895b482a8SLen Brown acpi_status status; 32995b482a8SLen Brown 33095b482a8SLen Brown ACPI_FUNCTION_TRACE(acpi_terminate); 33195b482a8SLen Brown 3322f977b36SBob Moore /* Just exit if subsystem is already shutdown */ 3332f977b36SBob Moore 3342f977b36SBob Moore if (acpi_gbl_shutdown) { 3352f977b36SBob Moore ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated")); 3362f977b36SBob Moore return_ACPI_STATUS(AE_OK); 3372f977b36SBob Moore } 3382f977b36SBob Moore 3392f977b36SBob Moore /* Subsystem appears active, go ahead and shut it down */ 3402f977b36SBob Moore 3412f977b36SBob Moore acpi_gbl_shutdown = TRUE; 3422f977b36SBob Moore acpi_gbl_startup_flags = 0; 3432f977b36SBob Moore ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); 3442f977b36SBob Moore 34595b482a8SLen Brown /* Terminate the AML Debugger if present */ 34695b482a8SLen Brown 34795b482a8SLen Brown ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE); 34895b482a8SLen Brown 34995b482a8SLen Brown /* Shutdown and free all resources */ 35095b482a8SLen Brown 35195b482a8SLen Brown acpi_ut_subsystem_shutdown(); 35295b482a8SLen Brown 35395b482a8SLen Brown /* Free the mutex objects */ 35495b482a8SLen Brown 35595b482a8SLen Brown acpi_ut_mutex_terminate(); 35695b482a8SLen Brown 35795b482a8SLen Brown #ifdef ACPI_DEBUGGER 35895b482a8SLen Brown 35995b482a8SLen Brown /* Shut down the debugger */ 36095b482a8SLen Brown 36195b482a8SLen Brown acpi_db_terminate(); 36295b482a8SLen Brown #endif 36395b482a8SLen Brown 36495b482a8SLen Brown /* Now we can shutdown the OS-dependent layer */ 36595b482a8SLen Brown 36695b482a8SLen Brown status = acpi_os_terminate(); 36795b482a8SLen Brown return_ACPI_STATUS(status); 36895b482a8SLen Brown } 36995b482a8SLen Brown 37095b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_terminate) 3712f977b36SBob Moore 37295b482a8SLen Brown #ifndef ACPI_ASL_COMPILER 37395b482a8SLen Brown #ifdef ACPI_FUTURE_USAGE 37495b482a8SLen Brown /******************************************************************************* 37595b482a8SLen Brown * 37695b482a8SLen Brown * FUNCTION: acpi_subsystem_status 37795b482a8SLen Brown * 37895b482a8SLen Brown * PARAMETERS: None 37995b482a8SLen Brown * 38095b482a8SLen Brown * RETURN: Status of the ACPI subsystem 38195b482a8SLen Brown * 38295b482a8SLen Brown * DESCRIPTION: Other drivers that use the ACPI subsystem should call this 38395b482a8SLen Brown * before making any other calls, to ensure the subsystem 38495b482a8SLen Brown * initialized successfully. 38595b482a8SLen Brown * 38695b482a8SLen Brown ******************************************************************************/ 38795b482a8SLen Brown acpi_status acpi_subsystem_status(void) 38895b482a8SLen Brown { 38995b482a8SLen Brown 39095b482a8SLen Brown if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { 39195b482a8SLen Brown return (AE_OK); 39295b482a8SLen Brown } else { 39395b482a8SLen Brown return (AE_ERROR); 39495b482a8SLen Brown } 39595b482a8SLen Brown } 39695b482a8SLen Brown 39795b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_subsystem_status) 39895b482a8SLen Brown 39995b482a8SLen Brown /******************************************************************************* 40095b482a8SLen Brown * 40195b482a8SLen Brown * FUNCTION: acpi_get_system_info 40295b482a8SLen Brown * 40395b482a8SLen Brown * PARAMETERS: out_buffer - A buffer to receive the resources for the 40495b482a8SLen Brown * device 40595b482a8SLen Brown * 40695b482a8SLen Brown * RETURN: Status - the status of the call 40795b482a8SLen Brown * 40895b482a8SLen Brown * DESCRIPTION: This function is called to get information about the current 40995b482a8SLen Brown * state of the ACPI subsystem. It will return system information 41095b482a8SLen Brown * in the out_buffer. 41195b482a8SLen Brown * 41295b482a8SLen Brown * If the function fails an appropriate status will be returned 41395b482a8SLen Brown * and the value of out_buffer is undefined. 41495b482a8SLen Brown * 41595b482a8SLen Brown ******************************************************************************/ 41695b482a8SLen Brown acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer) 41795b482a8SLen Brown { 41895b482a8SLen Brown struct acpi_system_info *info_ptr; 41995b482a8SLen Brown acpi_status status; 42095b482a8SLen Brown 42195b482a8SLen Brown ACPI_FUNCTION_TRACE(acpi_get_system_info); 42295b482a8SLen Brown 42395b482a8SLen Brown /* Parameter validation */ 42495b482a8SLen Brown 42595b482a8SLen Brown status = acpi_ut_validate_buffer(out_buffer); 42695b482a8SLen Brown if (ACPI_FAILURE(status)) { 42795b482a8SLen Brown return_ACPI_STATUS(status); 42895b482a8SLen Brown } 42995b482a8SLen Brown 43095b482a8SLen Brown /* Validate/Allocate/Clear caller buffer */ 43195b482a8SLen Brown 43295b482a8SLen Brown status = 43395b482a8SLen Brown acpi_ut_initialize_buffer(out_buffer, 43495b482a8SLen Brown sizeof(struct acpi_system_info)); 43595b482a8SLen Brown if (ACPI_FAILURE(status)) { 43695b482a8SLen Brown return_ACPI_STATUS(status); 43795b482a8SLen Brown } 43895b482a8SLen Brown 43995b482a8SLen Brown /* 44095b482a8SLen Brown * Populate the return buffer 44195b482a8SLen Brown */ 44295b482a8SLen Brown info_ptr = (struct acpi_system_info *)out_buffer->pointer; 44395b482a8SLen Brown 44495b482a8SLen Brown info_ptr->acpi_ca_version = ACPI_CA_VERSION; 44595b482a8SLen Brown 44695b482a8SLen Brown /* System flags (ACPI capabilities) */ 44795b482a8SLen Brown 44895b482a8SLen Brown info_ptr->flags = ACPI_SYS_MODE_ACPI; 44995b482a8SLen Brown 45095b482a8SLen Brown /* Timer resolution - 24 or 32 bits */ 45195b482a8SLen Brown 45295b482a8SLen Brown if (acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) { 45395b482a8SLen Brown info_ptr->timer_resolution = 24; 45495b482a8SLen Brown } else { 45595b482a8SLen Brown info_ptr->timer_resolution = 32; 45695b482a8SLen Brown } 45795b482a8SLen Brown 45895b482a8SLen Brown /* Clear the reserved fields */ 45995b482a8SLen Brown 46095b482a8SLen Brown info_ptr->reserved1 = 0; 46195b482a8SLen Brown info_ptr->reserved2 = 0; 46295b482a8SLen Brown 46395b482a8SLen Brown /* Current debug levels */ 46495b482a8SLen Brown 46595b482a8SLen Brown info_ptr->debug_layer = acpi_dbg_layer; 46695b482a8SLen Brown info_ptr->debug_level = acpi_dbg_level; 46795b482a8SLen Brown 46895b482a8SLen Brown return_ACPI_STATUS(AE_OK); 46995b482a8SLen Brown } 47095b482a8SLen Brown 47195b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_get_system_info) 47295b482a8SLen Brown 47395b482a8SLen Brown /***************************************************************************** 47495b482a8SLen Brown * 47595b482a8SLen Brown * FUNCTION: acpi_install_initialization_handler 47695b482a8SLen Brown * 47795b482a8SLen Brown * PARAMETERS: Handler - Callback procedure 47895b482a8SLen Brown * Function - Not (currently) used, see below 47995b482a8SLen Brown * 48095b482a8SLen Brown * RETURN: Status 48195b482a8SLen Brown * 48295b482a8SLen Brown * DESCRIPTION: Install an initialization handler 48395b482a8SLen Brown * 48495b482a8SLen Brown * TBD: When a second function is added, must save the Function also. 48595b482a8SLen Brown * 48695b482a8SLen Brown ****************************************************************************/ 48795b482a8SLen Brown acpi_status 48895b482a8SLen Brown acpi_install_initialization_handler(acpi_init_handler handler, u32 function) 48995b482a8SLen Brown { 49095b482a8SLen Brown 49195b482a8SLen Brown if (!handler) { 49295b482a8SLen Brown return (AE_BAD_PARAMETER); 49395b482a8SLen Brown } 49495b482a8SLen Brown 49595b482a8SLen Brown if (acpi_gbl_init_handler) { 49695b482a8SLen Brown return (AE_ALREADY_EXISTS); 49795b482a8SLen Brown } 49895b482a8SLen Brown 49995b482a8SLen Brown acpi_gbl_init_handler = handler; 50095b482a8SLen Brown return AE_OK; 50195b482a8SLen Brown } 50295b482a8SLen Brown 50395b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) 50495b482a8SLen Brown #endif /* ACPI_FUTURE_USAGE */ 505b0ed7a91SLin Ming 50695b482a8SLen Brown /***************************************************************************** 50795b482a8SLen Brown * 50895b482a8SLen Brown * FUNCTION: acpi_purge_cached_objects 50995b482a8SLen Brown * 51095b482a8SLen Brown * PARAMETERS: None 51195b482a8SLen Brown * 51295b482a8SLen Brown * RETURN: Status 51395b482a8SLen Brown * 51495b482a8SLen Brown * DESCRIPTION: Empty all caches (delete the cached objects) 51595b482a8SLen Brown * 51695b482a8SLen Brown ****************************************************************************/ 51795b482a8SLen Brown acpi_status acpi_purge_cached_objects(void) 51895b482a8SLen Brown { 51995b482a8SLen Brown ACPI_FUNCTION_TRACE(acpi_purge_cached_objects); 52095b482a8SLen Brown 52195b482a8SLen Brown (void)acpi_os_purge_cache(acpi_gbl_state_cache); 52295b482a8SLen Brown (void)acpi_os_purge_cache(acpi_gbl_operand_cache); 52395b482a8SLen Brown (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache); 52495b482a8SLen Brown (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache); 52595b482a8SLen Brown return_ACPI_STATUS(AE_OK); 52695b482a8SLen Brown } 52795b482a8SLen Brown 52895b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_purge_cached_objects) 529b0ed7a91SLin Ming 530b0ed7a91SLin Ming /***************************************************************************** 531b0ed7a91SLin Ming * 532b0ed7a91SLin Ming * FUNCTION: acpi_install_interface 533b0ed7a91SLin Ming * 534b0ed7a91SLin Ming * PARAMETERS: interface_name - The interface to install 535b0ed7a91SLin Ming * 536b0ed7a91SLin Ming * RETURN: Status 537b0ed7a91SLin Ming * 538b0ed7a91SLin Ming * DESCRIPTION: Install an _OSI interface to the global list 539b0ed7a91SLin Ming * 540b0ed7a91SLin Ming ****************************************************************************/ 541b0ed7a91SLin Ming acpi_status acpi_install_interface(acpi_string interface_name) 542b0ed7a91SLin Ming { 543b0ed7a91SLin Ming acpi_status status; 544b0ed7a91SLin Ming struct acpi_interface_info *interface_info; 545b0ed7a91SLin Ming 546b0ed7a91SLin Ming /* Parameter validation */ 547b0ed7a91SLin Ming 548b0ed7a91SLin Ming if (!interface_name || (ACPI_STRLEN(interface_name) == 0)) { 549b0ed7a91SLin Ming return (AE_BAD_PARAMETER); 550b0ed7a91SLin Ming } 551b0ed7a91SLin Ming 552b0ed7a91SLin Ming (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); 553b0ed7a91SLin Ming 554b0ed7a91SLin Ming /* Check if the interface name is already in the global list */ 555b0ed7a91SLin Ming 556b0ed7a91SLin Ming interface_info = acpi_ut_get_interface(interface_name); 557b0ed7a91SLin Ming if (interface_info) { 558b0ed7a91SLin Ming /* 559b0ed7a91SLin Ming * The interface already exists in the list. This is OK if the 560b0ed7a91SLin Ming * interface has been marked invalid -- just clear the bit. 561b0ed7a91SLin Ming */ 562b0ed7a91SLin Ming if (interface_info->flags & ACPI_OSI_INVALID) { 563b0ed7a91SLin Ming interface_info->flags &= ~ACPI_OSI_INVALID; 564b0ed7a91SLin Ming status = AE_OK; 565b0ed7a91SLin Ming } else { 566b0ed7a91SLin Ming status = AE_ALREADY_EXISTS; 567b0ed7a91SLin Ming } 568b0ed7a91SLin Ming } else { 569b0ed7a91SLin Ming /* New interface name, install into the global list */ 570b0ed7a91SLin Ming 571b0ed7a91SLin Ming status = acpi_ut_install_interface(interface_name); 572b0ed7a91SLin Ming } 573b0ed7a91SLin Ming 574b0ed7a91SLin Ming acpi_os_release_mutex(acpi_gbl_osi_mutex); 575b0ed7a91SLin Ming return (status); 576b0ed7a91SLin Ming } 577b0ed7a91SLin Ming 578b0ed7a91SLin Ming ACPI_EXPORT_SYMBOL(acpi_install_interface) 579b0ed7a91SLin Ming 580b0ed7a91SLin Ming /***************************************************************************** 581b0ed7a91SLin Ming * 582b0ed7a91SLin Ming * FUNCTION: acpi_remove_interface 583b0ed7a91SLin Ming * 584b0ed7a91SLin Ming * PARAMETERS: interface_name - The interface to remove 585b0ed7a91SLin Ming * 586b0ed7a91SLin Ming * RETURN: Status 587b0ed7a91SLin Ming * 588b0ed7a91SLin Ming * DESCRIPTION: Remove an _OSI interface from the global list 589b0ed7a91SLin Ming * 590b0ed7a91SLin Ming ****************************************************************************/ 591b0ed7a91SLin Ming acpi_status acpi_remove_interface(acpi_string interface_name) 592b0ed7a91SLin Ming { 593b0ed7a91SLin Ming acpi_status status; 594b0ed7a91SLin Ming 595b0ed7a91SLin Ming /* Parameter validation */ 596b0ed7a91SLin Ming 597b0ed7a91SLin Ming if (!interface_name || (ACPI_STRLEN(interface_name) == 0)) { 598b0ed7a91SLin Ming return (AE_BAD_PARAMETER); 599b0ed7a91SLin Ming } 600b0ed7a91SLin Ming 601b0ed7a91SLin Ming (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); 602b0ed7a91SLin Ming 603b0ed7a91SLin Ming status = acpi_ut_remove_interface(interface_name); 604b0ed7a91SLin Ming 605b0ed7a91SLin Ming acpi_os_release_mutex(acpi_gbl_osi_mutex); 606b0ed7a91SLin Ming return (status); 607b0ed7a91SLin Ming } 608b0ed7a91SLin Ming 609b0ed7a91SLin Ming ACPI_EXPORT_SYMBOL(acpi_remove_interface) 610b0ed7a91SLin Ming 611b0ed7a91SLin Ming /***************************************************************************** 612b0ed7a91SLin Ming * 613b0ed7a91SLin Ming * FUNCTION: acpi_install_interface_handler 614b0ed7a91SLin Ming * 615b0ed7a91SLin Ming * PARAMETERS: Handler - The _OSI interface handler to install 616b0ed7a91SLin Ming * NULL means "remove existing handler" 617b0ed7a91SLin Ming * 618b0ed7a91SLin Ming * RETURN: Status 619b0ed7a91SLin Ming * 620b0ed7a91SLin Ming * DESCRIPTION: Install a handler for the predefined _OSI ACPI method. 621b0ed7a91SLin Ming * invoked during execution of the internal implementation of 622b0ed7a91SLin Ming * _OSI. A NULL handler simply removes any existing handler. 623b0ed7a91SLin Ming * 624b0ed7a91SLin Ming ****************************************************************************/ 625b0ed7a91SLin Ming acpi_status acpi_install_interface_handler(acpi_interface_handler handler) 626b0ed7a91SLin Ming { 627b0ed7a91SLin Ming acpi_status status = AE_OK; 628b0ed7a91SLin Ming 629b0ed7a91SLin Ming (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); 630b0ed7a91SLin Ming 631b0ed7a91SLin Ming if (handler && acpi_gbl_interface_handler) { 632b0ed7a91SLin Ming status = AE_ALREADY_EXISTS; 633b0ed7a91SLin Ming } else { 634b0ed7a91SLin Ming acpi_gbl_interface_handler = handler; 635b0ed7a91SLin Ming } 636b0ed7a91SLin Ming 637b0ed7a91SLin Ming acpi_os_release_mutex(acpi_gbl_osi_mutex); 638b0ed7a91SLin Ming return (status); 639b0ed7a91SLin Ming } 640b0ed7a91SLin Ming 641b0ed7a91SLin Ming ACPI_EXPORT_SYMBOL(acpi_install_interface_handler) 642b0ed7a91SLin Ming #endif /* !ACPI_ASL_COMPILER */ 643