Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Module Name: utxface - External interfaces, miscellaneous utility functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define EXPORT_ACPI_INTERFACES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "acdebug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define _COMPONENT          ACPI_UTILITIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) ACPI_MODULE_NAME("utxface")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * FUNCTION:    acpi_terminate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) acpi_status ACPI_INIT_FUNCTION acpi_terminate(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	ACPI_FUNCTION_TRACE(acpi_terminate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	/* Shutdown and free all resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	acpi_ut_subsystem_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/* Free the mutex objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	acpi_ut_mutex_terminate();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	/* Now we can shutdown the OS-dependent layer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	status = acpi_os_terminate();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) ACPI_EXPORT_SYMBOL_INIT(acpi_terminate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #ifndef ACPI_ASL_COMPILER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #ifdef ACPI_FUTURE_USAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * FUNCTION:    acpi_subsystem_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * RETURN:      Status of the ACPI subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *              before making any other calls, to ensure the subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *              initialized successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) acpi_status acpi_subsystem_status(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return (AE_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) ACPI_EXPORT_SYMBOL(acpi_subsystem_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * FUNCTION:    acpi_get_system_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * PARAMETERS:  out_buffer      - A buffer to receive the resources for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *                                device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * RETURN:      status          - the status of the call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * DESCRIPTION: This function is called to get information about the current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *              state of the ACPI subsystem. It will return system information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *              in the out_buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *              If the function fails an appropriate status will be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  *              and the value of out_buffer is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) acpi_status acpi_get_system_info(struct acpi_buffer *out_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct acpi_system_info *info_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	ACPI_FUNCTION_TRACE(acpi_get_system_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	status = acpi_ut_validate_buffer(out_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	/* Validate/Allocate/Clear caller buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	    acpi_ut_initialize_buffer(out_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 				      sizeof(struct acpi_system_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	 * Populate the return buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	info_ptr = (struct acpi_system_info *)out_buffer->pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	info_ptr->acpi_ca_version = ACPI_CA_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	/* System flags (ACPI capabilities) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	info_ptr->flags = ACPI_SYS_MODE_ACPI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	/* Timer resolution - 24 or 32 bits  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	if (acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		info_ptr->timer_resolution = 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		info_ptr->timer_resolution = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	/* Clear the reserved fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	info_ptr->reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	info_ptr->reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	/* Current debug levels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	info_ptr->debug_layer = acpi_dbg_layer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	info_ptr->debug_level = acpi_dbg_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) ACPI_EXPORT_SYMBOL(acpi_get_system_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * FUNCTION:    acpi_get_statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * PARAMETERS:  stats           - Where the statistics are returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * RETURN:      status          - the status of the call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * DESCRIPTION: Get the contents of the various system counters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) acpi_status acpi_get_statistics(struct acpi_statistics *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	ACPI_FUNCTION_TRACE(acpi_get_statistics);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	if (!stats) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	/* Various interrupt-based event counters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	stats->sci_count = acpi_sci_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	stats->gpe_count = acpi_gpe_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	memcpy(stats->fixed_event_count, acpi_fixed_event_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	       sizeof(acpi_fixed_event_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	/* Other counters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	stats->method_count = acpi_method_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) ACPI_EXPORT_SYMBOL(acpi_get_statistics)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * FUNCTION:    acpi_install_initialization_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * PARAMETERS:  handler             - Callback procedure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *              function            - Not (currently) used, see below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * DESCRIPTION: Install an initialization handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  * TBD: When a second function is added, must save the Function also.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (!handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (acpi_gbl_init_handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return (AE_ALREADY_EXISTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	acpi_gbl_init_handler = handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * FUNCTION:    acpi_purge_cached_objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  * DESCRIPTION: Empty all caches (delete the cached objects)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) acpi_status acpi_purge_cached_objects(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	ACPI_FUNCTION_TRACE(acpi_purge_cached_objects);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	(void)acpi_os_purge_cache(acpi_gbl_state_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	(void)acpi_os_purge_cache(acpi_gbl_operand_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	(void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	(void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ACPI_EXPORT_SYMBOL(acpi_purge_cached_objects)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  * FUNCTION:    acpi_install_interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  * PARAMETERS:  interface_name      - The interface to install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  * DESCRIPTION: Install an _OSI interface to the global list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) acpi_status acpi_install_interface(acpi_string interface_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct acpi_interface_info *interface_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	if (!interface_name || (strlen(interface_name) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	/* Check if the interface name is already in the global list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	interface_info = acpi_ut_get_interface(interface_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	if (interface_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		 * The interface already exists in the list. This is OK if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		 * interface has been marked invalid -- just clear the bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		if (interface_info->flags & ACPI_OSI_INVALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			interface_info->flags &= ~ACPI_OSI_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			status = AE_ALREADY_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		/* New interface name, install into the global list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		status = acpi_ut_install_interface(interface_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) ACPI_EXPORT_SYMBOL(acpi_install_interface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  * FUNCTION:    acpi_remove_interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  * PARAMETERS:  interface_name      - The interface to remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)  * DESCRIPTION: Remove an _OSI interface from the global list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) acpi_status acpi_remove_interface(acpi_string interface_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (!interface_name || (strlen(interface_name) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	status = acpi_ut_remove_interface(interface_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ACPI_EXPORT_SYMBOL(acpi_remove_interface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  * FUNCTION:    acpi_install_interface_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  * PARAMETERS:  handler             - The _OSI interface handler to install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  *                                    NULL means "remove existing handler"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  *              invoked during execution of the internal implementation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  *              _OSI. A NULL handler simply removes any existing handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) acpi_status acpi_install_interface_handler(acpi_interface_handler handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	if (handler && acpi_gbl_interface_handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		status = AE_ALREADY_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		acpi_gbl_interface_handler = handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) ACPI_EXPORT_SYMBOL(acpi_install_interface_handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  * FUNCTION:    acpi_update_interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  * PARAMETERS:  action              - Actions to be performed during the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  *                                    update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  *              string or/and feature group strings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) acpi_status acpi_update_interfaces(u8 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	status = acpi_ut_update_interfaces(action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	acpi_os_release_mutex(acpi_gbl_osi_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  * FUNCTION:    acpi_check_address_range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  * PARAMETERS:  space_id            - Address space ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  *              address             - Start address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  *              length              - Length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  *              warn                - TRUE if warning on overlap desired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  * RETURN:      Count of the number of conflicts detected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  * DESCRIPTION: Check if the input address range overlaps any of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)  *              ASL operation region address ranges.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) acpi_check_address_range(acpi_adr_space_type space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			 acpi_physical_address address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			 acpi_size length, u8 warn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	u32 overlaps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		return (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	overlaps = acpi_ut_check_address_range(space_id, address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 					       (u32)length, warn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	return (overlaps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) ACPI_EXPORT_SYMBOL(acpi_check_address_range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) #endif				/* !ACPI_ASL_COMPILER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  * FUNCTION:    acpi_decode_pld_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)  * PARAMETERS:  in_buffer           - Buffer returned by _PLD method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  *              length              - Length of the in_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  *              return_buffer       - Where the decode buffer is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)  * RETURN:      Status and the decoded _PLD buffer. User must deallocate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)  *              the buffer via ACPI_FREE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)  * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)  *              a local struct that is much more useful to an ACPI driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) acpi_decode_pld_buffer(u8 *in_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		       acpi_size length, struct acpi_pld_info **return_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	struct acpi_pld_info *pld_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	u32 *buffer = ACPI_CAST_PTR(u32, in_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	u32 dword;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	if (!in_buffer || !return_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	    || (length < ACPI_PLD_REV1_BUFFER_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	pld_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pld_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	if (!pld_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	/* First 32-bit DWord */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	ACPI_MOVE_32_TO_32(&dword, &buffer[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	pld_info->revision = ACPI_PLD_GET_REVISION(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	pld_info->ignore_color = ACPI_PLD_GET_IGNORE_COLOR(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	pld_info->red = ACPI_PLD_GET_RED(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	pld_info->green = ACPI_PLD_GET_GREEN(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	pld_info->blue = ACPI_PLD_GET_BLUE(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	/* Second 32-bit DWord */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	ACPI_MOVE_32_TO_32(&dword, &buffer[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	pld_info->width = ACPI_PLD_GET_WIDTH(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	pld_info->height = ACPI_PLD_GET_HEIGHT(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	/* Third 32-bit DWord */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	ACPI_MOVE_32_TO_32(&dword, &buffer[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	pld_info->user_visible = ACPI_PLD_GET_USER_VISIBLE(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	pld_info->dock = ACPI_PLD_GET_DOCK(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	pld_info->lid = ACPI_PLD_GET_LID(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	pld_info->panel = ACPI_PLD_GET_PANEL(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	pld_info->vertical_position = ACPI_PLD_GET_VERTICAL(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	pld_info->horizontal_position = ACPI_PLD_GET_HORIZONTAL(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	pld_info->shape = ACPI_PLD_GET_SHAPE(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	pld_info->group_orientation = ACPI_PLD_GET_ORIENTATION(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	pld_info->group_token = ACPI_PLD_GET_TOKEN(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	pld_info->group_position = ACPI_PLD_GET_POSITION(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	pld_info->bay = ACPI_PLD_GET_BAY(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	/* Fourth 32-bit DWord */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	ACPI_MOVE_32_TO_32(&dword, &buffer[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	pld_info->ejectable = ACPI_PLD_GET_EJECTABLE(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	pld_info->ospm_eject_required = ACPI_PLD_GET_OSPM_EJECT(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	pld_info->cabinet_number = ACPI_PLD_GET_CABINET(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	pld_info->card_cage_number = ACPI_PLD_GET_CARD_CAGE(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	pld_info->reference = ACPI_PLD_GET_REFERENCE(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	pld_info->rotation = ACPI_PLD_GET_ROTATION(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	pld_info->order = ACPI_PLD_GET_ORDER(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	if (length >= ACPI_PLD_REV2_BUFFER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		/* Fifth 32-bit DWord (Revision 2 of _PLD) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		ACPI_MOVE_32_TO_32(&dword, &buffer[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		pld_info->vertical_offset = ACPI_PLD_GET_VERT_OFFSET(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		pld_info->horizontal_offset = ACPI_PLD_GET_HORIZ_OFFSET(&dword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	*return_buffer = pld_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) ACPI_EXPORT_SYMBOL(acpi_decode_pld_buffer)