xref: /openbmc/linux/drivers/acpi/acpica/utxface.c (revision c8100dc4)
195b482a8SLen Brown /******************************************************************************
295b482a8SLen Brown  *
3d978348bSBob Moore  * Module Name: utxface - External interfaces, miscellaneous utility functions
495b482a8SLen Brown  *
595b482a8SLen Brown  *****************************************************************************/
695b482a8SLen Brown 
795b482a8SLen Brown /*
8c8100dc4SBob Moore  * Copyright (C) 2000 - 2016, 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 
44839e928fSLv Zheng #define EXPORT_ACPI_INTERFACES
45839e928fSLv Zheng 
4695b482a8SLen Brown #include <acpi/acpi.h>
47e2f7a777SLen Brown #include "accommon.h"
48e2f7a777SLen Brown #include "acdebug.h"
4995b482a8SLen Brown 
5095b482a8SLen Brown #define _COMPONENT          ACPI_UTILITIES
5195b482a8SLen Brown ACPI_MODULE_NAME("utxface")
5295b482a8SLen Brown 
5395b482a8SLen Brown /*******************************************************************************
5495b482a8SLen Brown  *
5595b482a8SLen Brown  * FUNCTION:    acpi_terminate
5695b482a8SLen Brown  *
5795b482a8SLen Brown  * PARAMETERS:  None
5895b482a8SLen Brown  *
5995b482a8SLen Brown  * RETURN:      Status
6095b482a8SLen Brown  *
612f977b36SBob Moore  * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
6295b482a8SLen Brown  *
6395b482a8SLen Brown  ******************************************************************************/
6445c9f78bSLv Zheng acpi_status __init acpi_terminate(void)
6595b482a8SLen Brown {
6695b482a8SLen Brown 	acpi_status status;
6795b482a8SLen Brown 
6895b482a8SLen Brown 	ACPI_FUNCTION_TRACE(acpi_terminate);
6995b482a8SLen Brown 
7095b482a8SLen Brown 	/* Shutdown and free all resources */
7195b482a8SLen Brown 
7295b482a8SLen Brown 	acpi_ut_subsystem_shutdown();
7395b482a8SLen Brown 
7495b482a8SLen Brown 	/* Free the mutex objects */
7595b482a8SLen Brown 
7695b482a8SLen Brown 	acpi_ut_mutex_terminate();
7795b482a8SLen Brown 
7895b482a8SLen Brown 	/* Now we can shutdown the OS-dependent layer */
7995b482a8SLen Brown 
8095b482a8SLen Brown 	status = acpi_os_terminate();
8195b482a8SLen Brown 	return_ACPI_STATUS(status);
8295b482a8SLen Brown }
8395b482a8SLen Brown 
84d21f600bSLv Zheng ACPI_EXPORT_SYMBOL_INIT(acpi_terminate)
852f977b36SBob Moore 
8695b482a8SLen Brown #ifndef ACPI_ASL_COMPILER
8795b482a8SLen Brown #ifdef ACPI_FUTURE_USAGE
8895b482a8SLen Brown /*******************************************************************************
8995b482a8SLen Brown  *
9095b482a8SLen Brown  * FUNCTION:    acpi_subsystem_status
9195b482a8SLen Brown  *
9295b482a8SLen Brown  * PARAMETERS:  None
9395b482a8SLen Brown  *
9495b482a8SLen Brown  * RETURN:      Status of the ACPI subsystem
9595b482a8SLen Brown  *
9695b482a8SLen Brown  * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
9795b482a8SLen Brown  *              before making any other calls, to ensure the subsystem
9895b482a8SLen Brown  *              initialized successfully.
9995b482a8SLen Brown  *
10095b482a8SLen Brown  ******************************************************************************/
10195b482a8SLen Brown acpi_status acpi_subsystem_status(void)
10295b482a8SLen Brown {
10395b482a8SLen Brown 
10495b482a8SLen Brown 	if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
10595b482a8SLen Brown 		return (AE_OK);
10695b482a8SLen Brown 	} else {
10795b482a8SLen Brown 		return (AE_ERROR);
10895b482a8SLen Brown 	}
10995b482a8SLen Brown }
11095b482a8SLen Brown 
11195b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_subsystem_status)
11295b482a8SLen Brown 
11395b482a8SLen Brown /*******************************************************************************
11495b482a8SLen Brown  *
11595b482a8SLen Brown  * FUNCTION:    acpi_get_system_info
11695b482a8SLen Brown  *
11795b482a8SLen Brown  * PARAMETERS:  out_buffer      - A buffer to receive the resources for the
11895b482a8SLen Brown  *                                device
11995b482a8SLen Brown  *
120ba494beeSBob Moore  * RETURN:      status          - the status of the call
12195b482a8SLen Brown  *
12295b482a8SLen Brown  * DESCRIPTION: This function is called to get information about the current
12395b482a8SLen Brown  *              state of the ACPI subsystem. It will return system information
12495b482a8SLen Brown  *              in the out_buffer.
12595b482a8SLen Brown  *
12695b482a8SLen Brown  *              If the function fails an appropriate status will be returned
12795b482a8SLen Brown  *              and the value of out_buffer is undefined.
12895b482a8SLen Brown  *
12995b482a8SLen Brown  ******************************************************************************/
13095b482a8SLen Brown acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)
13195b482a8SLen Brown {
13295b482a8SLen Brown 	struct acpi_system_info *info_ptr;
13395b482a8SLen Brown 	acpi_status status;
13495b482a8SLen Brown 
13595b482a8SLen Brown 	ACPI_FUNCTION_TRACE(acpi_get_system_info);
13695b482a8SLen Brown 
13795b482a8SLen Brown 	/* Parameter validation */
13895b482a8SLen Brown 
13995b482a8SLen Brown 	status = acpi_ut_validate_buffer(out_buffer);
14095b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
14195b482a8SLen Brown 		return_ACPI_STATUS(status);
14295b482a8SLen Brown 	}
14395b482a8SLen Brown 
14495b482a8SLen Brown 	/* Validate/Allocate/Clear caller buffer */
14595b482a8SLen Brown 
14695b482a8SLen Brown 	status =
14795b482a8SLen Brown 	    acpi_ut_initialize_buffer(out_buffer,
14895b482a8SLen Brown 				      sizeof(struct acpi_system_info));
14995b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
15095b482a8SLen Brown 		return_ACPI_STATUS(status);
15195b482a8SLen Brown 	}
15295b482a8SLen Brown 
15395b482a8SLen Brown 	/*
15495b482a8SLen Brown 	 * Populate the return buffer
15595b482a8SLen Brown 	 */
15695b482a8SLen Brown 	info_ptr = (struct acpi_system_info *)out_buffer->pointer;
15795b482a8SLen Brown 	info_ptr->acpi_ca_version = ACPI_CA_VERSION;
15895b482a8SLen Brown 
15995b482a8SLen Brown 	/* System flags (ACPI capabilities) */
16095b482a8SLen Brown 
16195b482a8SLen Brown 	info_ptr->flags = ACPI_SYS_MODE_ACPI;
16295b482a8SLen Brown 
16395b482a8SLen Brown 	/* Timer resolution - 24 or 32 bits  */
16495b482a8SLen Brown 
16595b482a8SLen Brown 	if (acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) {
16695b482a8SLen Brown 		info_ptr->timer_resolution = 24;
16795b482a8SLen Brown 	} else {
16895b482a8SLen Brown 		info_ptr->timer_resolution = 32;
16995b482a8SLen Brown 	}
17095b482a8SLen Brown 
17195b482a8SLen Brown 	/* Clear the reserved fields */
17295b482a8SLen Brown 
17395b482a8SLen Brown 	info_ptr->reserved1 = 0;
17495b482a8SLen Brown 	info_ptr->reserved2 = 0;
17595b482a8SLen Brown 
17695b482a8SLen Brown 	/* Current debug levels */
17795b482a8SLen Brown 
17895b482a8SLen Brown 	info_ptr->debug_layer = acpi_dbg_layer;
17995b482a8SLen Brown 	info_ptr->debug_level = acpi_dbg_level;
18095b482a8SLen Brown 
18195b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
18295b482a8SLen Brown }
18395b482a8SLen Brown 
18495b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_get_system_info)
18595b482a8SLen Brown 
1869187a415SLv Zheng /*******************************************************************************
1879187a415SLv Zheng  *
1889187a415SLv Zheng  * FUNCTION:    acpi_get_statistics
1899187a415SLv Zheng  *
1909187a415SLv Zheng  * PARAMETERS:  stats           - Where the statistics are returned
1919187a415SLv Zheng  *
1929187a415SLv Zheng  * RETURN:      status          - the status of the call
1939187a415SLv Zheng  *
1949187a415SLv Zheng  * DESCRIPTION: Get the contents of the various system counters
1959187a415SLv Zheng  *
1969187a415SLv Zheng  ******************************************************************************/
1979187a415SLv Zheng acpi_status acpi_get_statistics(struct acpi_statistics *stats)
1989187a415SLv Zheng {
1999187a415SLv Zheng 	ACPI_FUNCTION_TRACE(acpi_get_statistics);
2009187a415SLv Zheng 
2019187a415SLv Zheng 	/* Parameter validation */
2029187a415SLv Zheng 
2039187a415SLv Zheng 	if (!stats) {
2049187a415SLv Zheng 		return_ACPI_STATUS(AE_BAD_PARAMETER);
2059187a415SLv Zheng 	}
2069187a415SLv Zheng 
2079187a415SLv Zheng 	/* Various interrupt-based event counters */
2089187a415SLv Zheng 
2099187a415SLv Zheng 	stats->sci_count = acpi_sci_count;
2109187a415SLv Zheng 	stats->gpe_count = acpi_gpe_count;
2119187a415SLv Zheng 
2124fa4616eSBob Moore 	memcpy(stats->fixed_event_count, acpi_fixed_event_count,
2139187a415SLv Zheng 	       sizeof(acpi_fixed_event_count));
2149187a415SLv Zheng 
2159187a415SLv Zheng 	/* Other counters */
2169187a415SLv Zheng 
2179187a415SLv Zheng 	stats->method_count = acpi_method_count;
2189187a415SLv Zheng 	return_ACPI_STATUS(AE_OK);
2199187a415SLv Zheng }
2209187a415SLv Zheng 
2219187a415SLv Zheng ACPI_EXPORT_SYMBOL(acpi_get_statistics)
2229187a415SLv Zheng 
22395b482a8SLen Brown /*****************************************************************************
22495b482a8SLen Brown  *
22595b482a8SLen Brown  * FUNCTION:    acpi_install_initialization_handler
22695b482a8SLen Brown  *
227ba494beeSBob Moore  * PARAMETERS:  handler             - Callback procedure
228ba494beeSBob Moore  *              function            - Not (currently) used, see below
22995b482a8SLen Brown  *
23095b482a8SLen Brown  * RETURN:      Status
23195b482a8SLen Brown  *
23295b482a8SLen Brown  * DESCRIPTION: Install an initialization handler
23395b482a8SLen Brown  *
23495b482a8SLen Brown  * TBD: When a second function is added, must save the Function also.
23595b482a8SLen Brown  *
23695b482a8SLen Brown  ****************************************************************************/
23795b482a8SLen Brown acpi_status
23895b482a8SLen Brown acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
23995b482a8SLen Brown {
24095b482a8SLen Brown 
24195b482a8SLen Brown 	if (!handler) {
24295b482a8SLen Brown 		return (AE_BAD_PARAMETER);
24395b482a8SLen Brown 	}
24495b482a8SLen Brown 
24595b482a8SLen Brown 	if (acpi_gbl_init_handler) {
24695b482a8SLen Brown 		return (AE_ALREADY_EXISTS);
24795b482a8SLen Brown 	}
24895b482a8SLen Brown 
24995b482a8SLen Brown 	acpi_gbl_init_handler = handler;
25068aafc35SBob Moore 	return (AE_OK);
25195b482a8SLen Brown }
25295b482a8SLen Brown 
25395b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler)
2544d946f79SLv Zheng #endif
255b0ed7a91SLin Ming 
25695b482a8SLen Brown /*****************************************************************************
25795b482a8SLen Brown  *
25895b482a8SLen Brown  * FUNCTION:    acpi_purge_cached_objects
25995b482a8SLen Brown  *
26095b482a8SLen Brown  * PARAMETERS:  None
26195b482a8SLen Brown  *
26295b482a8SLen Brown  * RETURN:      Status
26395b482a8SLen Brown  *
26495b482a8SLen Brown  * DESCRIPTION: Empty all caches (delete the cached objects)
26595b482a8SLen Brown  *
26695b482a8SLen Brown  ****************************************************************************/
26795b482a8SLen Brown acpi_status acpi_purge_cached_objects(void)
26895b482a8SLen Brown {
26995b482a8SLen Brown 	ACPI_FUNCTION_TRACE(acpi_purge_cached_objects);
27095b482a8SLen Brown 
27195b482a8SLen Brown 	(void)acpi_os_purge_cache(acpi_gbl_state_cache);
27295b482a8SLen Brown 	(void)acpi_os_purge_cache(acpi_gbl_operand_cache);
27395b482a8SLen Brown 	(void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
27495b482a8SLen Brown 	(void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
27568aafc35SBob Moore 
27695b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
27795b482a8SLen Brown }
27895b482a8SLen Brown 
27995b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_purge_cached_objects)
280b0ed7a91SLin Ming 
281b0ed7a91SLin Ming /*****************************************************************************
282b0ed7a91SLin Ming  *
283b0ed7a91SLin Ming  * FUNCTION:    acpi_install_interface
284b0ed7a91SLin Ming  *
285b0ed7a91SLin Ming  * PARAMETERS:  interface_name      - The interface to install
286b0ed7a91SLin Ming  *
287b0ed7a91SLin Ming  * RETURN:      Status
288b0ed7a91SLin Ming  *
289b0ed7a91SLin Ming  * DESCRIPTION: Install an _OSI interface to the global list
290b0ed7a91SLin Ming  *
291b0ed7a91SLin Ming  ****************************************************************************/
292b0ed7a91SLin Ming acpi_status acpi_install_interface(acpi_string interface_name)
293b0ed7a91SLin Ming {
294b0ed7a91SLin Ming 	acpi_status status;
295b0ed7a91SLin Ming 	struct acpi_interface_info *interface_info;
296b0ed7a91SLin Ming 
297b0ed7a91SLin Ming 	/* Parameter validation */
298b0ed7a91SLin Ming 
2994fa4616eSBob Moore 	if (!interface_name || (strlen(interface_name) == 0)) {
300b0ed7a91SLin Ming 		return (AE_BAD_PARAMETER);
301b0ed7a91SLin Ming 	}
302b0ed7a91SLin Ming 
303388a9902SJung-uk Kim 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
304388a9902SJung-uk Kim 	if (ACPI_FAILURE(status)) {
305388a9902SJung-uk Kim 		return (status);
306388a9902SJung-uk Kim 	}
307b0ed7a91SLin Ming 
308b0ed7a91SLin Ming 	/* Check if the interface name is already in the global list */
309b0ed7a91SLin Ming 
310b0ed7a91SLin Ming 	interface_info = acpi_ut_get_interface(interface_name);
311b0ed7a91SLin Ming 	if (interface_info) {
312b0ed7a91SLin Ming 		/*
313b0ed7a91SLin Ming 		 * The interface already exists in the list. This is OK if the
314b0ed7a91SLin Ming 		 * interface has been marked invalid -- just clear the bit.
315b0ed7a91SLin Ming 		 */
316b0ed7a91SLin Ming 		if (interface_info->flags & ACPI_OSI_INVALID) {
317b0ed7a91SLin Ming 			interface_info->flags &= ~ACPI_OSI_INVALID;
318b0ed7a91SLin Ming 			status = AE_OK;
319b0ed7a91SLin Ming 		} else {
320b0ed7a91SLin Ming 			status = AE_ALREADY_EXISTS;
321b0ed7a91SLin Ming 		}
322b0ed7a91SLin Ming 	} else {
323b0ed7a91SLin Ming 		/* New interface name, install into the global list */
324b0ed7a91SLin Ming 
325b0ed7a91SLin Ming 		status = acpi_ut_install_interface(interface_name);
326b0ed7a91SLin Ming 	}
327b0ed7a91SLin Ming 
328b0ed7a91SLin Ming 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
329b0ed7a91SLin Ming 	return (status);
330b0ed7a91SLin Ming }
331b0ed7a91SLin Ming 
332b0ed7a91SLin Ming ACPI_EXPORT_SYMBOL(acpi_install_interface)
333b0ed7a91SLin Ming 
334b0ed7a91SLin Ming /*****************************************************************************
335b0ed7a91SLin Ming  *
336b0ed7a91SLin Ming  * FUNCTION:    acpi_remove_interface
337b0ed7a91SLin Ming  *
338b0ed7a91SLin Ming  * PARAMETERS:  interface_name      - The interface to remove
339b0ed7a91SLin Ming  *
340b0ed7a91SLin Ming  * RETURN:      Status
341b0ed7a91SLin Ming  *
342b0ed7a91SLin Ming  * DESCRIPTION: Remove an _OSI interface from the global list
343b0ed7a91SLin Ming  *
344b0ed7a91SLin Ming  ****************************************************************************/
345b0ed7a91SLin Ming acpi_status acpi_remove_interface(acpi_string interface_name)
346b0ed7a91SLin Ming {
347b0ed7a91SLin Ming 	acpi_status status;
348b0ed7a91SLin Ming 
349b0ed7a91SLin Ming 	/* Parameter validation */
350b0ed7a91SLin Ming 
3514fa4616eSBob Moore 	if (!interface_name || (strlen(interface_name) == 0)) {
352b0ed7a91SLin Ming 		return (AE_BAD_PARAMETER);
353b0ed7a91SLin Ming 	}
354b0ed7a91SLin Ming 
355388a9902SJung-uk Kim 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
356388a9902SJung-uk Kim 	if (ACPI_FAILURE(status)) {
357388a9902SJung-uk Kim 		return (status);
358388a9902SJung-uk Kim 	}
359b0ed7a91SLin Ming 
360b0ed7a91SLin Ming 	status = acpi_ut_remove_interface(interface_name);
361b0ed7a91SLin Ming 
362b0ed7a91SLin Ming 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
363b0ed7a91SLin Ming 	return (status);
364b0ed7a91SLin Ming }
365b0ed7a91SLin Ming 
366b0ed7a91SLin Ming ACPI_EXPORT_SYMBOL(acpi_remove_interface)
367b0ed7a91SLin Ming 
368b0ed7a91SLin Ming /*****************************************************************************
369b0ed7a91SLin Ming  *
370b0ed7a91SLin Ming  * FUNCTION:    acpi_install_interface_handler
371b0ed7a91SLin Ming  *
372ba494beeSBob Moore  * PARAMETERS:  handler             - The _OSI interface handler to install
373b0ed7a91SLin Ming  *                                    NULL means "remove existing handler"
374b0ed7a91SLin Ming  *
375b0ed7a91SLin Ming  * RETURN:      Status
376b0ed7a91SLin Ming  *
377b0ed7a91SLin Ming  * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
378b0ed7a91SLin Ming  *              invoked during execution of the internal implementation of
379b0ed7a91SLin Ming  *              _OSI. A NULL handler simply removes any existing handler.
380b0ed7a91SLin Ming  *
381b0ed7a91SLin Ming  ****************************************************************************/
382b0ed7a91SLin Ming acpi_status acpi_install_interface_handler(acpi_interface_handler handler)
383b0ed7a91SLin Ming {
384388a9902SJung-uk Kim 	acpi_status status;
385b0ed7a91SLin Ming 
386388a9902SJung-uk Kim 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
387388a9902SJung-uk Kim 	if (ACPI_FAILURE(status)) {
388388a9902SJung-uk Kim 		return (status);
389388a9902SJung-uk Kim 	}
390b0ed7a91SLin Ming 
391b0ed7a91SLin Ming 	if (handler && acpi_gbl_interface_handler) {
392b0ed7a91SLin Ming 		status = AE_ALREADY_EXISTS;
393b0ed7a91SLin Ming 	} else {
394b0ed7a91SLin Ming 		acpi_gbl_interface_handler = handler;
395b0ed7a91SLin Ming 	}
396b0ed7a91SLin Ming 
397b0ed7a91SLin Ming 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
398b0ed7a91SLin Ming 	return (status);
399b0ed7a91SLin Ming }
400b0ed7a91SLin Ming 
401b0ed7a91SLin Ming ACPI_EXPORT_SYMBOL(acpi_install_interface_handler)
402f654c0feSLin Ming 
403f654c0feSLin Ming /*****************************************************************************
404f654c0feSLin Ming  *
4052cf9f5bcSLv Zheng  * FUNCTION:    acpi_update_interfaces
4062cf9f5bcSLv Zheng  *
4072cf9f5bcSLv Zheng  * PARAMETERS:  action              - Actions to be performed during the
4082cf9f5bcSLv Zheng  *                                    update
4092cf9f5bcSLv Zheng  *
4102cf9f5bcSLv Zheng  * RETURN:      Status
4112cf9f5bcSLv Zheng  *
4122cf9f5bcSLv Zheng  * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
4132cf9f5bcSLv Zheng  *              string or/and feature group strings.
4142cf9f5bcSLv Zheng  *
4152cf9f5bcSLv Zheng  ****************************************************************************/
4162cf9f5bcSLv Zheng acpi_status acpi_update_interfaces(u8 action)
4172cf9f5bcSLv Zheng {
4182cf9f5bcSLv Zheng 	acpi_status status;
4192cf9f5bcSLv Zheng 
4202cf9f5bcSLv Zheng 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
4212cf9f5bcSLv Zheng 	if (ACPI_FAILURE(status)) {
4222cf9f5bcSLv Zheng 		return (status);
4232cf9f5bcSLv Zheng 	}
4242cf9f5bcSLv Zheng 
4252cf9f5bcSLv Zheng 	status = acpi_ut_update_interfaces(action);
4262cf9f5bcSLv Zheng 
4272cf9f5bcSLv Zheng 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
4282cf9f5bcSLv Zheng 	return (status);
4292cf9f5bcSLv Zheng }
4302cf9f5bcSLv Zheng 
4312cf9f5bcSLv Zheng /*****************************************************************************
4322cf9f5bcSLv Zheng  *
433f654c0feSLin Ming  * FUNCTION:    acpi_check_address_range
434f654c0feSLin Ming  *
435f654c0feSLin Ming  * PARAMETERS:  space_id            - Address space ID
436ba494beeSBob Moore  *              address             - Start address
437ba494beeSBob Moore  *              length              - Length
438ba494beeSBob Moore  *              warn                - TRUE if warning on overlap desired
439f654c0feSLin Ming  *
440f654c0feSLin Ming  * RETURN:      Count of the number of conflicts detected.
441f654c0feSLin Ming  *
442f654c0feSLin Ming  * DESCRIPTION: Check if the input address range overlaps any of the
443f654c0feSLin Ming  *              ASL operation region address ranges.
444f654c0feSLin Ming  *
445f654c0feSLin Ming  ****************************************************************************/
4462cf9f5bcSLv Zheng 
447f654c0feSLin Ming u32
448f654c0feSLin Ming acpi_check_address_range(acpi_adr_space_type space_id,
449f654c0feSLin Ming 			 acpi_physical_address address,
450f654c0feSLin Ming 			 acpi_size length, u8 warn)
451f654c0feSLin Ming {
452f654c0feSLin Ming 	u32 overlaps;
453f654c0feSLin Ming 	acpi_status status;
454f654c0feSLin Ming 
455f654c0feSLin Ming 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
456f654c0feSLin Ming 	if (ACPI_FAILURE(status)) {
457f654c0feSLin Ming 		return (0);
458f654c0feSLin Ming 	}
459f654c0feSLin Ming 
460f654c0feSLin Ming 	overlaps = acpi_ut_check_address_range(space_id, address,
461f654c0feSLin Ming 					       (u32)length, warn);
462f654c0feSLin Ming 
463f654c0feSLin Ming 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
464f654c0feSLin Ming 	return (overlaps);
465f654c0feSLin Ming }
466f654c0feSLin Ming 
467f654c0feSLin Ming ACPI_EXPORT_SYMBOL(acpi_check_address_range)
468b0ed7a91SLin Ming #endif				/* !ACPI_ASL_COMPILER */
469be030a57SBob Moore /*******************************************************************************
470be030a57SBob Moore  *
471be030a57SBob Moore  * FUNCTION:    acpi_decode_pld_buffer
472be030a57SBob Moore  *
473be030a57SBob Moore  * PARAMETERS:  in_buffer           - Buffer returned by _PLD method
474be030a57SBob Moore  *              length              - Length of the in_buffer
475be030a57SBob Moore  *              return_buffer       - Where the decode buffer is returned
476be030a57SBob Moore  *
477be030a57SBob Moore  * RETURN:      Status and the decoded _PLD buffer. User must deallocate
478be030a57SBob Moore  *              the buffer via ACPI_FREE.
479be030a57SBob Moore  *
480be030a57SBob Moore  * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
481be030a57SBob Moore  *              a local struct that is much more useful to an ACPI driver.
482be030a57SBob Moore  *
483be030a57SBob Moore  ******************************************************************************/
484be030a57SBob Moore acpi_status
485be030a57SBob Moore acpi_decode_pld_buffer(u8 *in_buffer,
486be030a57SBob Moore 		       acpi_size length, struct acpi_pld_info ** return_buffer)
487be030a57SBob Moore {
488be030a57SBob Moore 	struct acpi_pld_info *pld_info;
489be030a57SBob Moore 	u32 *buffer = ACPI_CAST_PTR(u32, in_buffer);
490be030a57SBob Moore 	u32 dword;
491be030a57SBob Moore 
492be030a57SBob Moore 	/* Parameter validation */
493be030a57SBob Moore 
49435349697SBob Moore 	if (!in_buffer || !return_buffer
49535349697SBob Moore 	    || (length < ACPI_PLD_REV1_BUFFER_SIZE)) {
496be030a57SBob Moore 		return (AE_BAD_PARAMETER);
497be030a57SBob Moore 	}
498be030a57SBob Moore 
499be030a57SBob Moore 	pld_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pld_info));
500be030a57SBob Moore 	if (!pld_info) {
501be030a57SBob Moore 		return (AE_NO_MEMORY);
502be030a57SBob Moore 	}
503be030a57SBob Moore 
504be030a57SBob Moore 	/* First 32-bit DWord */
505be030a57SBob Moore 
506be030a57SBob Moore 	ACPI_MOVE_32_TO_32(&dword, &buffer[0]);
507be030a57SBob Moore 	pld_info->revision = ACPI_PLD_GET_REVISION(&dword);
508be030a57SBob Moore 	pld_info->ignore_color = ACPI_PLD_GET_IGNORE_COLOR(&dword);
5094dcd78d8SBob Moore 	pld_info->red = ACPI_PLD_GET_RED(&dword);
5104dcd78d8SBob Moore 	pld_info->green = ACPI_PLD_GET_GREEN(&dword);
5114dcd78d8SBob Moore 	pld_info->blue = ACPI_PLD_GET_BLUE(&dword);
512be030a57SBob Moore 
513be030a57SBob Moore 	/* Second 32-bit DWord */
514be030a57SBob Moore 
515be030a57SBob Moore 	ACPI_MOVE_32_TO_32(&dword, &buffer[1]);
516be030a57SBob Moore 	pld_info->width = ACPI_PLD_GET_WIDTH(&dword);
517be030a57SBob Moore 	pld_info->height = ACPI_PLD_GET_HEIGHT(&dword);
518be030a57SBob Moore 
519be030a57SBob Moore 	/* Third 32-bit DWord */
520be030a57SBob Moore 
521be030a57SBob Moore 	ACPI_MOVE_32_TO_32(&dword, &buffer[2]);
522be030a57SBob Moore 	pld_info->user_visible = ACPI_PLD_GET_USER_VISIBLE(&dword);
523be030a57SBob Moore 	pld_info->dock = ACPI_PLD_GET_DOCK(&dword);
524be030a57SBob Moore 	pld_info->lid = ACPI_PLD_GET_LID(&dword);
525be030a57SBob Moore 	pld_info->panel = ACPI_PLD_GET_PANEL(&dword);
526be030a57SBob Moore 	pld_info->vertical_position = ACPI_PLD_GET_VERTICAL(&dword);
527be030a57SBob Moore 	pld_info->horizontal_position = ACPI_PLD_GET_HORIZONTAL(&dword);
528be030a57SBob Moore 	pld_info->shape = ACPI_PLD_GET_SHAPE(&dword);
529be030a57SBob Moore 	pld_info->group_orientation = ACPI_PLD_GET_ORIENTATION(&dword);
530be030a57SBob Moore 	pld_info->group_token = ACPI_PLD_GET_TOKEN(&dword);
531be030a57SBob Moore 	pld_info->group_position = ACPI_PLD_GET_POSITION(&dword);
532be030a57SBob Moore 	pld_info->bay = ACPI_PLD_GET_BAY(&dword);
533be030a57SBob Moore 
534be030a57SBob Moore 	/* Fourth 32-bit DWord */
535be030a57SBob Moore 
536be030a57SBob Moore 	ACPI_MOVE_32_TO_32(&dword, &buffer[3]);
537be030a57SBob Moore 	pld_info->ejectable = ACPI_PLD_GET_EJECTABLE(&dword);
538be030a57SBob Moore 	pld_info->ospm_eject_required = ACPI_PLD_GET_OSPM_EJECT(&dword);
539be030a57SBob Moore 	pld_info->cabinet_number = ACPI_PLD_GET_CABINET(&dword);
540be030a57SBob Moore 	pld_info->card_cage_number = ACPI_PLD_GET_CARD_CAGE(&dword);
541be030a57SBob Moore 	pld_info->reference = ACPI_PLD_GET_REFERENCE(&dword);
542be030a57SBob Moore 	pld_info->rotation = ACPI_PLD_GET_ROTATION(&dword);
543be030a57SBob Moore 	pld_info->order = ACPI_PLD_GET_ORDER(&dword);
544be030a57SBob Moore 
54535349697SBob Moore 	if (length >= ACPI_PLD_REV2_BUFFER_SIZE) {
546be030a57SBob Moore 
547be030a57SBob Moore 		/* Fifth 32-bit DWord (Revision 2 of _PLD) */
548be030a57SBob Moore 
549be030a57SBob Moore 		ACPI_MOVE_32_TO_32(&dword, &buffer[4]);
550be030a57SBob Moore 		pld_info->vertical_offset = ACPI_PLD_GET_VERT_OFFSET(&dword);
551be030a57SBob Moore 		pld_info->horizontal_offset = ACPI_PLD_GET_HORIZ_OFFSET(&dword);
552be030a57SBob Moore 	}
553be030a57SBob Moore 
554be030a57SBob Moore 	*return_buffer = pld_info;
555be030a57SBob Moore 	return (AE_OK);
556be030a57SBob Moore }
557be030a57SBob Moore 
558be030a57SBob Moore ACPI_EXPORT_SYMBOL(acpi_decode_pld_buffer)
559