Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: utmisc - common utility procedures |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
David E. Box | 82a8094 | 2015-02-05 15:20:45 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2015, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "acnamesp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT ACPI_UTILITIES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("utmisc") |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 50 | |
Bob Moore | c6e1733 | 2012-05-22 16:26:53 +0800 | [diff] [blame] | 51 | /******************************************************************************* |
| 52 | * |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 53 | * FUNCTION: acpi_ut_is_pci_root_bridge |
| 54 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 55 | * PARAMETERS: id - The HID/CID in string format |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 56 | * |
| 57 | * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge |
| 58 | * |
| 59 | * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. |
| 60 | * |
| 61 | ******************************************************************************/ |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 62 | u8 acpi_ut_is_pci_root_bridge(char *id) |
| 63 | { |
| 64 | |
| 65 | /* |
| 66 | * Check if this is a PCI root bridge. |
| 67 | * ACPI 3.0+: check for a PCI Express root also. |
| 68 | */ |
| 69 | if (!(ACPI_STRCMP(id, |
| 70 | PCI_ROOT_HID_STRING)) || |
| 71 | !(ACPI_STRCMP(id, PCI_EXPRESS_ROOT_HID_STRING))) { |
| 72 | return (TRUE); |
| 73 | } |
| 74 | |
| 75 | return (FALSE); |
| 76 | } |
| 77 | |
Lv Zheng | 6306bf8 | 2015-04-13 11:49:39 +0800 | [diff] [blame] | 78 | #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP) |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 79 | /******************************************************************************* |
| 80 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 81 | * FUNCTION: acpi_ut_is_aml_table |
| 82 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 83 | * PARAMETERS: table - An ACPI table |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 84 | * |
| 85 | * RETURN: TRUE if table contains executable AML; FALSE otherwise |
| 86 | * |
| 87 | * DESCRIPTION: Check ACPI Signature for a table that contains AML code. |
| 88 | * Currently, these are DSDT,SSDT,PSDT. All other table types are |
| 89 | * data tables that do not contain AML code. |
| 90 | * |
| 91 | ******************************************************************************/ |
Bob Moore | 84fb2c9 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 92 | |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 93 | u8 acpi_ut_is_aml_table(struct acpi_table_header *table) |
| 94 | { |
| 95 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 96 | /* These are the only tables that contain executable AML */ |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 97 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 98 | if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) || |
| 99 | ACPI_COMPARE_NAME(table->signature, ACPI_SIG_PSDT) || |
| 100 | ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 101 | return (TRUE); |
| 102 | } |
| 103 | |
| 104 | return (FALSE); |
| 105 | } |
Lv Zheng | 6306bf8 | 2015-04-13 11:49:39 +0800 | [diff] [blame] | 106 | #endif |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 107 | |
| 108 | /******************************************************************************* |
| 109 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | * FUNCTION: acpi_ut_dword_byte_swap |
| 111 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 112 | * PARAMETERS: value - Value to be converted |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 114 | * RETURN: u32 integer with bytes swapped |
| 115 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) |
| 117 | * |
| 118 | ******************************************************************************/ |
| 119 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 120 | u32 acpi_ut_dword_byte_swap(u32 value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | { |
| 122 | union { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 123 | u32 value; |
| 124 | u8 bytes[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | } out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | union { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 127 | u32 value; |
| 128 | u8 bytes[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } in; |
| 130 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 131 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | in.value = value; |
| 134 | |
| 135 | out.bytes[0] = in.bytes[3]; |
| 136 | out.bytes[1] = in.bytes[2]; |
| 137 | out.bytes[2] = in.bytes[1]; |
| 138 | out.bytes[3] = in.bytes[0]; |
| 139 | |
| 140 | return (out.value); |
| 141 | } |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | /******************************************************************************* |
| 144 | * |
| 145 | * FUNCTION: acpi_ut_set_integer_width |
| 146 | * |
| 147 | * PARAMETERS: Revision From DSDT header |
| 148 | * |
| 149 | * RETURN: None |
| 150 | * |
| 151 | * DESCRIPTION: Set the global integer bit width based upon the revision |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 152 | * of the DSDT. For Revision 1 and 0, Integers are 32 bits. |
| 153 | * For Revision 2 and above, Integers are 64 bits. Yes, this |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | * makes a difference. |
| 155 | * |
| 156 | ******************************************************************************/ |
| 157 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | void acpi_ut_set_integer_width(u8 revision) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | { |
| 160 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 161 | if (revision < 2) { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 162 | |
| 163 | /* 32-bit case */ |
| 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | acpi_gbl_integer_bit_width = 32; |
| 166 | acpi_gbl_integer_nybble_width = 8; |
| 167 | acpi_gbl_integer_byte_width = 4; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 168 | } else { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 169 | /* 64-bit case (ACPI 2.0+) */ |
| 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | acpi_gbl_integer_bit_width = 64; |
| 172 | acpi_gbl_integer_nybble_width = 16; |
| 173 | acpi_gbl_integer_byte_width = 8; |
| 174 | } |
| 175 | } |
| 176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | /******************************************************************************* |
| 178 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | * FUNCTION: acpi_ut_create_update_state_and_push |
| 180 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 181 | * PARAMETERS: object - Object to be added to the new state |
| 182 | * action - Increment/Decrement |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | * state_list - List the state will be added to |
| 184 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 185 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | * |
| 187 | * DESCRIPTION: Create a new state and push it |
| 188 | * |
| 189 | ******************************************************************************/ |
| 190 | |
| 191 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 192 | acpi_ut_create_update_state_and_push(union acpi_operand_object *object, |
| 193 | u16 action, |
| 194 | union acpi_generic_state **state_list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 196 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 198 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | /* Ignore null objects; these are expected */ |
| 201 | |
| 202 | if (!object) { |
| 203 | return (AE_OK); |
| 204 | } |
| 205 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 206 | state = acpi_ut_create_update_state(object, action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | if (!state) { |
| 208 | return (AE_NO_MEMORY); |
| 209 | } |
| 210 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | acpi_ut_push_generic_state(state_list, state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | return (AE_OK); |
| 213 | } |
| 214 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | /******************************************************************************* |
| 216 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | * FUNCTION: acpi_ut_walk_package_tree |
| 218 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 219 | * PARAMETERS: source_object - The package to walk |
| 220 | * target_object - Target object (if package is being copied) |
| 221 | * walk_callback - Called once for each package element |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 222 | * context - Passed to the callback function |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | * |
| 224 | * RETURN: Status |
| 225 | * |
| 226 | * DESCRIPTION: Walk through a package |
| 227 | * |
| 228 | ******************************************************************************/ |
| 229 | |
| 230 | acpi_status |
Lv Zheng | 6d33b6b | 2012-10-31 02:25:05 +0000 | [diff] [blame] | 231 | acpi_ut_walk_package_tree(union acpi_operand_object *source_object, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | void *target_object, |
| 233 | acpi_pkg_callback walk_callback, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | acpi_status status = AE_OK; |
| 236 | union acpi_generic_state *state_list = NULL; |
| 237 | union acpi_generic_state *state; |
| 238 | u32 this_index; |
| 239 | union acpi_operand_object *this_source_obj; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 241 | ACPI_FUNCTION_TRACE(ut_walk_package_tree); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | state = acpi_ut_create_pkg_state(source_object, target_object, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 245 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | while (state) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | /* Get one element of the package */ |
| 251 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 252 | this_index = state->pkg.index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | this_source_obj = (union acpi_operand_object *) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | state->pkg.source_object->package.elements[this_index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
| 256 | /* |
| 257 | * Check for: |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 258 | * 1) An uninitialized package element. It is completely |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | * legal to declare a package and leave it uninitialized |
| 260 | * 2) Not an internal object - can be a namespace node instead |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 261 | * 3) Any type other than a package. Packages are handled in else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | * case below. |
| 263 | */ |
| 264 | if ((!this_source_obj) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 265 | (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != |
| 266 | ACPI_DESC_TYPE_OPERAND) |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 267 | || (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | status = |
| 269 | walk_callback(ACPI_COPY_TYPE_SIMPLE, |
| 270 | this_source_obj, state, context); |
| 271 | if (ACPI_FAILURE(status)) { |
| 272 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | state->pkg.index++; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 276 | while (state->pkg.index >= |
| 277 | state->pkg.source_object->package.count) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | /* |
| 279 | * We've handled all of the objects at this level, This means |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 280 | * that we have just completed a package. That package may |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | * have contained one or more packages itself. |
| 282 | * |
| 283 | * Delete this state and pop the previous state (package). |
| 284 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 285 | acpi_ut_delete_generic_state(state); |
| 286 | state = acpi_ut_pop_generic_state(&state_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | /* Finished when there are no more states */ |
| 289 | |
| 290 | if (!state) { |
| 291 | /* |
| 292 | * We have handled all of the objects in the top level |
| 293 | * package just add the length of the package objects |
| 294 | * and exit |
| 295 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | /* |
| 300 | * Go back up a level and move the index past the just |
| 301 | * completed package object. |
| 302 | */ |
| 303 | state->pkg.index++; |
| 304 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | /* This is a subobject of type package */ |
| 307 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | status = |
| 309 | walk_callback(ACPI_COPY_TYPE_PACKAGE, |
| 310 | this_source_obj, state, context); |
| 311 | if (ACPI_FAILURE(status)) { |
| 312 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* |
| 316 | * Push the current state and create a new one |
| 317 | * The callback above returned a new target package object. |
| 318 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 319 | acpi_ut_push_generic_state(&state_list, state); |
| 320 | state = acpi_ut_create_pkg_state(this_source_obj, |
| 321 | state->pkg. |
| 322 | this_target_obj, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | if (!state) { |
Lin Ming | cf058bd | 2008-09-27 11:29:57 +0800 | [diff] [blame] | 324 | |
| 325 | /* Free any stacked Update State objects */ |
| 326 | |
| 327 | while (state_list) { |
| 328 | state = |
| 329 | acpi_ut_pop_generic_state |
| 330 | (&state_list); |
| 331 | acpi_ut_delete_generic_state(state); |
| 332 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | /* We should never get here */ |
| 339 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
Bob Moore | 42f8fb7 | 2013-01-11 13:08:51 +0100 | [diff] [blame] | 342 | |
| 343 | #ifdef ACPI_DEBUG_OUTPUT |
| 344 | /******************************************************************************* |
| 345 | * |
| 346 | * FUNCTION: acpi_ut_display_init_pathname |
| 347 | * |
| 348 | * PARAMETERS: type - Object type of the node |
| 349 | * obj_handle - Handle whose pathname will be displayed |
| 350 | * path - Additional path string to be appended. |
| 351 | * (NULL if no extra path) |
| 352 | * |
| 353 | * RETURN: acpi_status |
| 354 | * |
| 355 | * DESCRIPTION: Display full pathname of an object, DEBUG ONLY |
| 356 | * |
| 357 | ******************************************************************************/ |
| 358 | |
| 359 | void |
| 360 | acpi_ut_display_init_pathname(u8 type, |
| 361 | struct acpi_namespace_node *obj_handle, |
| 362 | char *path) |
| 363 | { |
| 364 | acpi_status status; |
| 365 | struct acpi_buffer buffer; |
| 366 | |
| 367 | ACPI_FUNCTION_ENTRY(); |
| 368 | |
| 369 | /* Only print the path if the appropriate debug level is enabled */ |
| 370 | |
| 371 | if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { |
| 372 | return; |
| 373 | } |
| 374 | |
| 375 | /* Get the full pathname to the node */ |
| 376 | |
| 377 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
| 378 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); |
| 379 | if (ACPI_FAILURE(status)) { |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | /* Print what we're doing */ |
| 384 | |
| 385 | switch (type) { |
| 386 | case ACPI_TYPE_METHOD: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 387 | |
Bob Moore | 42f8fb7 | 2013-01-11 13:08:51 +0100 | [diff] [blame] | 388 | acpi_os_printf("Executing "); |
| 389 | break; |
| 390 | |
| 391 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 392 | |
Bob Moore | 42f8fb7 | 2013-01-11 13:08:51 +0100 | [diff] [blame] | 393 | acpi_os_printf("Initializing "); |
| 394 | break; |
| 395 | } |
| 396 | |
| 397 | /* Print the object type and pathname */ |
| 398 | |
| 399 | acpi_os_printf("%-12s %s", |
| 400 | acpi_ut_get_type_name(type), (char *)buffer.pointer); |
| 401 | |
| 402 | /* Extra path is used to append names like _STA, _INI, etc. */ |
| 403 | |
| 404 | if (path) { |
| 405 | acpi_os_printf(".%s", path); |
| 406 | } |
| 407 | acpi_os_printf("\n"); |
| 408 | |
| 409 | ACPI_FREE(buffer.pointer); |
| 410 | } |
| 411 | #endif |