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: utmisc - common utility procedures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define _COMPONENT          ACPI_UTILITIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) ACPI_MODULE_NAME("utmisc")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * FUNCTION:    acpi_ut_is_pci_root_bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * PARAMETERS:  id              - The HID/CID in string format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * RETURN:      TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) u8 acpi_ut_is_pci_root_bridge(char *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) {
^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) 	 * Check if this is a PCI root bridge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	 * ACPI 3.0+: check for a PCI Express root also.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	if (!(strcmp(id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		     PCI_ROOT_HID_STRING)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	    !(strcmp(id, PCI_EXPRESS_ROOT_HID_STRING))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		return (TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	return (FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * FUNCTION:    acpi_ut_is_aml_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * PARAMETERS:  table               - An ACPI table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * RETURN:      TRUE if table contains executable AML; FALSE otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *              Currently, these are DSDT,SSDT,PSDT. All other table types are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *              data tables that do not contain AML code.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/* These are the only tables that contain executable AML */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_DSDT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	    ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_PSDT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	    ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_SSDT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	    ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_OSDT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	    ACPI_IS_OEM_SIG(table->signature)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		return (TRUE);
^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) 	return (FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^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)  * FUNCTION:    acpi_ut_dword_byte_swap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * PARAMETERS:  value           - Value to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * RETURN:      u32 integer with bytes swapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) u32 acpi_ut_dword_byte_swap(u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		u8 bytes[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	} out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		u8 bytes[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	} in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	in.value = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	out.bytes[0] = in.bytes[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	out.bytes[1] = in.bytes[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	out.bytes[2] = in.bytes[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	out.bytes[3] = in.bytes[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	return (out.value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^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)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * FUNCTION:    acpi_ut_set_integer_width
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * PARAMETERS:  Revision            From DSDT header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * DESCRIPTION: Set the global integer bit width based upon the revision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *              of the DSDT. For Revision 1 and 0, Integers are 32 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *              For Revision 2 and above, Integers are 64 bits. Yes, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *              makes a difference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) void acpi_ut_set_integer_width(u8 revision)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	if (revision < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		/* 32-bit case */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		acpi_gbl_integer_bit_width = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		acpi_gbl_integer_nybble_width = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		acpi_gbl_integer_byte_width = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		/* 64-bit case (ACPI 2.0+) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		acpi_gbl_integer_bit_width = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		acpi_gbl_integer_nybble_width = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		acpi_gbl_integer_byte_width = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * FUNCTION:    acpi_ut_create_update_state_and_push
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * PARAMETERS:  object          - Object to be added to the new state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *              action          - Increment/Decrement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *              state_list      - List the state will be added to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * DESCRIPTION: Create a new state and push it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 				     u16 action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 				     union acpi_generic_state **state_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	union acpi_generic_state *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	/* Ignore null objects; these are expected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if (!object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	state = acpi_ut_create_update_state(object, action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (!state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	acpi_ut_push_generic_state(state_list, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * FUNCTION:    acpi_ut_walk_package_tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * PARAMETERS:  source_object       - The package to walk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *              target_object       - Target object (if package is being copied)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *              walk_callback       - Called once for each package element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *              context             - Passed to the callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * DESCRIPTION: Walk through a package, including subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			  void *target_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			  acpi_pkg_callback walk_callback, void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	union acpi_generic_state *state_list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	union acpi_generic_state *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	union acpi_operand_object *this_source_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	u32 this_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	ACPI_FUNCTION_TRACE(ut_walk_package_tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	state = acpi_ut_create_pkg_state(source_object, target_object, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (!state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	while (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		/* Get one element of the package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		this_index = state->pkg.index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		this_source_obj =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		    state->pkg.source_object->package.elements[this_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		state->pkg.this_target_obj =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		    &state->pkg.source_object->package.elements[this_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		 * Check for:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		 * 1) An uninitialized package element. It is completely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		 *    legal to declare a package and leave it uninitialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		 * 2) Not an internal object - can be a namespace node instead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		 * 3) Any type other than a package. Packages are handled in else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		 *    case below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		if ((!this_source_obj) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		    (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		     ACPI_DESC_TYPE_OPERAND) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		    (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			    walk_callback(ACPI_COPY_TYPE_SIMPLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					  this_source_obj, state, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 				return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			state->pkg.index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			while (state->pkg.index >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			       state->pkg.source_object->package.count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 				 * We've handled all of the objects at this level,  This means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				 * that we have just completed a package. That package may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				 * have contained one or more packages itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 				 * Delete this state and pop the previous state (package).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 				acpi_ut_delete_generic_state(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 				state = acpi_ut_pop_generic_state(&state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 				/* Finished when there are no more states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 				if (!state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 					/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 					 * We have handled all of the objects in the top level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 					 * package just add the length of the package objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 					 * and exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 					return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 				 * Go back up a level and move the index past the just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				 * completed package object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 				state->pkg.index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			/* This is a subobject of type package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			    walk_callback(ACPI_COPY_TYPE_PACKAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 					  this_source_obj, state, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 				return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			 * Push the current state and create a new one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			 * The callback above returned a new target package object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			acpi_ut_push_generic_state(&state_list, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			state =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			    acpi_ut_create_pkg_state(this_source_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 						     state->pkg.this_target_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 						     0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			if (!state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				/* Free any stacked Update State objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				while (state_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 					state =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 					    acpi_ut_pop_generic_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 					    (&state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 					acpi_ut_delete_generic_state(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 				return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	/* We should never get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	ACPI_ERROR((AE_INFO, "State list did not terminate correctly"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	return_ACPI_STATUS(AE_AML_INTERNAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #ifdef ACPI_DEBUG_OUTPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  * FUNCTION:    acpi_ut_display_init_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  * PARAMETERS:  type                - Object type of the node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  *              obj_handle          - Handle whose pathname will be displayed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  *              path                - Additional path string to be appended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  *                                      (NULL if no extra path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  * RETURN:      acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) acpi_ut_display_init_pathname(u8 type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			      struct acpi_namespace_node *obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 			      const char *path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	struct acpi_buffer buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	/* Only print the path if the appropriate debug level is enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	/* Get the full pathname to the node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	/* Print what we're doing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	case ACPI_TYPE_METHOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		acpi_os_printf("Executing  ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		acpi_os_printf("Initializing ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	/* Print the object type and pathname */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	acpi_os_printf("%-12s %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		       acpi_ut_get_type_name(type), (char *)buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	/* Extra path is used to append names like _STA, _INI, etc. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	if (path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		acpi_os_printf(".%s", path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	acpi_os_printf("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	ACPI_FREE(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #endif