| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 |  | 
|  | 2 | /****************************************************************************** | 
|  | 3 | * | 
|  | 4 | * Module Name: exstore - AML Interpreter object store support | 
|  | 5 | * | 
|  | 6 | *****************************************************************************/ | 
|  | 7 |  | 
|  | 8 | /* | 
| Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2008, Intel Corp. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. | 
|  | 11 | * | 
|  | 12 | * Redistribution and use in source and binary forms, with or without | 
|  | 13 | * modification, are permitted provided that the following conditions | 
|  | 14 | * are met: | 
|  | 15 | * 1. Redistributions of source code must retain the above copyright | 
|  | 16 | *    notice, this list of conditions, and the following disclaimer, | 
|  | 17 | *    without modification. | 
|  | 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 
|  | 19 | *    substantially similar to the "NO WARRANTY" disclaimer below | 
|  | 20 | *    ("Disclaimer") and any redistribution must be conditioned upon | 
|  | 21 | *    including a substantially similar Disclaimer requirement for further | 
|  | 22 | *    binary redistribution. | 
|  | 23 | * 3. Neither the names of the above-listed copyright holders nor the names | 
|  | 24 | *    of any contributors may be used to endorse or promote products derived | 
|  | 25 | *    from this software without specific prior written permission. | 
|  | 26 | * | 
|  | 27 | * Alternatively, this software may be distributed under the terms of the | 
|  | 28 | * GNU General Public License ("GPL") version 2 as published by the Free | 
|  | 29 | * Software Foundation. | 
|  | 30 | * | 
|  | 31 | * NO WARRANTY | 
|  | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
|  | 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
|  | 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 
|  | 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
|  | 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|  | 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|  | 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|  | 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
|  | 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
|  | 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|  | 42 | * POSSIBILITY OF SUCH DAMAGES. | 
|  | 43 | */ | 
|  | 44 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <acpi/acpi.h> | 
|  | 46 | #include <acpi/acdispat.h> | 
|  | 47 | #include <acpi/acinterp.h> | 
|  | 48 | #include <acpi/amlcode.h> | 
|  | 49 | #include <acpi/acnamesp.h> | 
|  | 50 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define _COMPONENT          ACPI_EXECUTER | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | ACPI_MODULE_NAME("exstore") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 | /* Local prototypes */ | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 | static void | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | 
|  | 57 | u32 level, u32 index); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 58 |  | 
|  | 59 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 60 | acpi_ex_store_object_to_index(union acpi_operand_object *val_desc, | 
|  | 61 | union acpi_operand_object *dest_desc, | 
|  | 62 | struct acpi_walk_state *walk_state); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 63 |  | 
|  | 64 | /******************************************************************************* | 
|  | 65 | * | 
|  | 66 | * FUNCTION:    acpi_ex_do_debug_object | 
|  | 67 | * | 
|  | 68 | * PARAMETERS:  source_desc         - Value to be stored | 
|  | 69 | *              Level               - Indentation level (used for packages) | 
|  | 70 | *              Index               - Current package element, zero if not pkg | 
|  | 71 | * | 
|  | 72 | * RETURN:      None | 
|  | 73 | * | 
|  | 74 | * DESCRIPTION: Handles stores to the Debug Object. | 
|  | 75 | * | 
|  | 76 | ******************************************************************************/ | 
|  | 77 |  | 
|  | 78 | static void | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 79 | acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | 
|  | 80 | u32 level, u32 index) | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 81 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | u32 i; | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 83 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 84 | ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 85 |  | 
| Bob Moore | d884657 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 86 | /* Print line header as long as we are not in the middle of an object display */ | 
|  | 87 |  | 
|  | 88 | if (!((level > 0) && index == 0)) { | 
|  | 89 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", | 
|  | 90 | level, " ")); | 
|  | 91 | } | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 92 |  | 
|  | 93 | /* Display index for package output only */ | 
|  | 94 |  | 
|  | 95 | if (index > 0) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 96 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
|  | 97 | "(%.2u) ", index - 1)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 98 | } | 
|  | 99 |  | 
|  | 100 | if (!source_desc) { | 
| Bob Moore | d884657 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 101 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n")); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 102 | return_VOID; | 
|  | 103 | } | 
|  | 104 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 105 | if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) { | 
| Bob Moore | d884657 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 106 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s ", | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 107 | acpi_ut_get_object_type_name | 
|  | 108 | (source_desc))); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 109 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 110 | if (!acpi_ut_valid_internal_object(source_desc)) { | 
|  | 111 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
|  | 112 | "%p, Invalid Internal Object!\n", | 
|  | 113 | source_desc)); | 
|  | 114 | return_VOID; | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 115 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == | 
|  | 117 | ACPI_DESC_TYPE_NAMED) { | 
|  | 118 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", | 
|  | 119 | acpi_ut_get_type_name(((struct | 
|  | 120 | acpi_namespace_node | 
|  | 121 | *)source_desc)-> | 
|  | 122 | type), | 
|  | 123 | source_desc)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 124 | return_VOID; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 125 | } else { | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 126 | return_VOID; | 
|  | 127 | } | 
|  | 128 |  | 
| Bob Moore | 61ce421 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 129 | /* source_desc is of type ACPI_DESC_TYPE_OPERAND */ | 
|  | 130 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 131 | switch (ACPI_GET_OBJECT_TYPE(source_desc)) { | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 132 | case ACPI_TYPE_INTEGER: | 
|  | 133 |  | 
|  | 134 | /* Output correct integer width */ | 
|  | 135 |  | 
|  | 136 | if (acpi_gbl_integer_byte_width == 4) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", | 
|  | 138 | (u32) source_desc->integer. | 
|  | 139 | value)); | 
|  | 140 | } else { | 
|  | 141 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
|  | 142 | "0x%8.8X%8.8X\n", | 
|  | 143 | ACPI_FORMAT_UINT64(source_desc-> | 
|  | 144 | integer. | 
|  | 145 | value))); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 146 | } | 
|  | 147 | break; | 
|  | 148 |  | 
|  | 149 | case ACPI_TYPE_BUFFER: | 
|  | 150 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 151 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", | 
|  | 152 | (u32) source_desc->buffer.length)); | 
|  | 153 | ACPI_DUMP_BUFFER(source_desc->buffer.pointer, | 
|  | 154 | (source_desc->buffer.length < | 
| Bob Moore | 422f4f9 | 2008-04-10 19:06:37 +0400 | [diff] [blame] | 155 | 256) ? source_desc->buffer.length : 256); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 156 | break; | 
|  | 157 |  | 
|  | 158 | case ACPI_TYPE_STRING: | 
|  | 159 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 160 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", | 
|  | 161 | source_desc->string.length, | 
|  | 162 | source_desc->string.pointer)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 163 | break; | 
|  | 164 |  | 
|  | 165 | case ACPI_TYPE_PACKAGE: | 
|  | 166 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 167 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
| Bob Moore | d884657 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 168 | "[Contains 0x%.2X Elements]\n", | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 169 | source_desc->package.count)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 170 |  | 
|  | 171 | /* Output the entire contents of the package */ | 
|  | 172 |  | 
|  | 173 | for (i = 0; i < source_desc->package.count; i++) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 174 | acpi_ex_do_debug_object(source_desc->package. | 
|  | 175 | elements[i], level + 4, i + 1); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 176 | } | 
|  | 177 | break; | 
|  | 178 |  | 
|  | 179 | case ACPI_TYPE_LOCAL_REFERENCE: | 
|  | 180 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 181 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s] ", | 
|  | 182 | acpi_ut_get_reference_name(source_desc))); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 183 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 184 | /* Decode the reference */ | 
|  | 185 |  | 
|  | 186 | switch (source_desc->reference.class) { | 
|  | 187 | case ACPI_REFCLASS_INDEX: | 
|  | 188 |  | 
|  | 189 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%X\n", | 
| Bob Moore | 57e664c | 2008-09-27 10:40:39 +0800 | [diff] [blame] | 190 | source_desc->reference.value)); | 
| Bob Moore | 61ce421 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 191 | break; | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 192 |  | 
|  | 193 | case ACPI_REFCLASS_TABLE: | 
|  | 194 |  | 
|  | 195 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
|  | 196 | "Table Index 0x%X\n", | 
|  | 197 | source_desc->reference.value)); | 
|  | 198 | break; | 
|  | 199 |  | 
|  | 200 | default: | 
|  | 201 | break; | 
| Bob Moore | 61ce421 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 202 | } | 
|  | 203 |  | 
| Bob Moore | d884657 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 204 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "  ")); | 
|  | 205 |  | 
|  | 206 | /* Check for valid node first, then valid object */ | 
|  | 207 |  | 
|  | 208 | if (source_desc->reference.node) { | 
|  | 209 | if (ACPI_GET_DESCRIPTOR_TYPE | 
|  | 210 | (source_desc->reference.node) != | 
|  | 211 | ACPI_DESC_TYPE_NAMED) { | 
|  | 212 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
|  | 213 | " %p - Not a valid namespace node\n", | 
|  | 214 | source_desc->reference. | 
|  | 215 | node)); | 
|  | 216 | } else { | 
|  | 217 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, | 
|  | 218 | "Node %p [%4.4s] ", | 
|  | 219 | source_desc->reference. | 
|  | 220 | node, | 
|  | 221 | (source_desc->reference. | 
|  | 222 | node)->name.ascii)); | 
|  | 223 |  | 
|  | 224 | switch ((source_desc->reference.node)->type) { | 
|  | 225 |  | 
|  | 226 | /* These types have no attached object */ | 
|  | 227 |  | 
|  | 228 | case ACPI_TYPE_DEVICE: | 
|  | 229 | acpi_os_printf("Device\n"); | 
|  | 230 | break; | 
|  | 231 |  | 
|  | 232 | case ACPI_TYPE_THERMAL: | 
|  | 233 | acpi_os_printf("Thermal Zone\n"); | 
|  | 234 | break; | 
|  | 235 |  | 
|  | 236 | default: | 
|  | 237 | acpi_ex_do_debug_object((source_desc-> | 
|  | 238 | reference. | 
|  | 239 | node)->object, | 
|  | 240 | level + 4, 0); | 
|  | 241 | break; | 
|  | 242 | } | 
|  | 243 | } | 
|  | 244 | } else if (source_desc->reference.object) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 245 | if (ACPI_GET_DESCRIPTOR_TYPE | 
|  | 246 | (source_desc->reference.object) == | 
|  | 247 | ACPI_DESC_TYPE_NAMED) { | 
|  | 248 | acpi_ex_do_debug_object(((struct | 
|  | 249 | acpi_namespace_node *) | 
|  | 250 | source_desc->reference. | 
|  | 251 | object)->object, | 
|  | 252 | level + 4, 0); | 
|  | 253 | } else { | 
|  | 254 | acpi_ex_do_debug_object(source_desc->reference. | 
|  | 255 | object, level + 4, 0); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 256 | } | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 257 | } | 
|  | 258 | break; | 
|  | 259 |  | 
|  | 260 | default: | 
|  | 261 |  | 
| Bob Moore | d884657 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 262 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%p\n", | 
|  | 263 | source_desc)); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 264 | break; | 
|  | 265 | } | 
|  | 266 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 267 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n")); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 268 | return_VOID; | 
|  | 269 | } | 
|  | 270 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | /******************************************************************************* | 
|  | 272 | * | 
|  | 273 | * FUNCTION:    acpi_ex_store | 
|  | 274 | * | 
|  | 275 | * PARAMETERS:  *source_desc        - Value to be stored | 
|  | 276 | *              *dest_desc          - Where to store it.  Must be an NS node | 
|  | 277 | *                                    or an union acpi_operand_object of type | 
|  | 278 | *                                    Reference; | 
|  | 279 | *              walk_state          - Current walk state | 
|  | 280 | * | 
|  | 281 | * RETURN:      Status | 
|  | 282 | * | 
|  | 283 | * DESCRIPTION: Store the value described by source_desc into the location | 
|  | 284 | *              described by dest_desc. Called by various interpreter | 
|  | 285 | *              functions to store the result of an operation into | 
|  | 286 | *              the destination operand -- not just simply the actual "Store" | 
|  | 287 | *              ASL operator. | 
|  | 288 | * | 
|  | 289 | ******************************************************************************/ | 
|  | 290 |  | 
|  | 291 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 292 | acpi_ex_store(union acpi_operand_object *source_desc, | 
|  | 293 | union acpi_operand_object *dest_desc, | 
|  | 294 | struct acpi_walk_state *walk_state) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | acpi_status status = AE_OK; | 
|  | 297 | union acpi_operand_object *ref_desc = dest_desc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 299 | ACPI_FUNCTION_TRACE_PTR(ex_store, dest_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 |  | 
|  | 301 | /* Validate parameters */ | 
|  | 302 |  | 
|  | 303 | if (!source_desc || !dest_desc) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 304 | ACPI_ERROR((AE_INFO, "Null parameter")); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | return_ACPI_STATUS(AE_AML_NO_OPERAND); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } | 
|  | 307 |  | 
|  | 308 | /* dest_desc can be either a namespace node or an ACPI object */ | 
|  | 309 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | /* | 
|  | 312 | * Dest is a namespace node, | 
|  | 313 | * Storing an object into a Named node. | 
|  | 314 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 315 | status = acpi_ex_store_object_to_node(source_desc, | 
|  | 316 | (struct | 
|  | 317 | acpi_namespace_node *) | 
|  | 318 | dest_desc, walk_state, | 
|  | 319 | ACPI_IMPLICIT_CONVERSION); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 321 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } | 
|  | 323 |  | 
|  | 324 | /* Destination object must be a Reference or a Constant object */ | 
|  | 325 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 326 | switch (ACPI_GET_OBJECT_TYPE(dest_desc)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | case ACPI_TYPE_LOCAL_REFERENCE: | 
|  | 328 | break; | 
|  | 329 |  | 
|  | 330 | case ACPI_TYPE_INTEGER: | 
|  | 331 |  | 
|  | 332 | /* Allow stores to Constants -- a Noop as per ACPI spec */ | 
|  | 333 |  | 
|  | 334 | if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 335 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | } | 
|  | 337 |  | 
|  | 338 | /*lint -fallthrough */ | 
|  | 339 |  | 
|  | 340 | default: | 
|  | 341 |  | 
|  | 342 | /* Destination is not a Reference object */ | 
|  | 343 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 344 | ACPI_ERROR((AE_INFO, | 
|  | 345 | "Target is not a Reference or Constant object - %s [%p]", | 
|  | 346 | acpi_ut_get_object_type_name(dest_desc), | 
|  | 347 | dest_desc)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 349 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } | 
|  | 351 |  | 
|  | 352 | /* | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 353 | * Examine the Reference class. These cases are handled: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | * | 
|  | 355 | * 1) Store to Name (Change the object associated with a name) | 
|  | 356 | * 2) Store to an indexed area of a Buffer or Package | 
|  | 357 | * 3) Store to a Method Local or Arg | 
|  | 358 | * 4) Store to the debug object | 
|  | 359 | */ | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 360 | switch (ref_desc->reference.class) { | 
|  | 361 | case ACPI_REFCLASS_REFOF: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 |  | 
|  | 363 | /* Storing an object into a Name "container" */ | 
|  | 364 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 365 | status = acpi_ex_store_object_to_node(source_desc, | 
|  | 366 | ref_desc->reference. | 
|  | 367 | object, walk_state, | 
|  | 368 | ACPI_IMPLICIT_CONVERSION); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | break; | 
|  | 370 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 371 | case ACPI_REFCLASS_INDEX: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 |  | 
|  | 373 | /* Storing to an Index (pointer into a packager or buffer) */ | 
|  | 374 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 375 | status = | 
|  | 376 | acpi_ex_store_object_to_index(source_desc, ref_desc, | 
|  | 377 | walk_state); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | break; | 
|  | 379 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 380 | case ACPI_REFCLASS_LOCAL: | 
|  | 381 | case ACPI_REFCLASS_ARG: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 |  | 
|  | 383 | /* Store to a method local/arg  */ | 
|  | 384 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 385 | status = | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 386 | acpi_ds_store_object_to_local(ref_desc->reference.class, | 
|  | 387 | ref_desc->reference.value, | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 388 | source_desc, walk_state); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | break; | 
|  | 390 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 391 | case ACPI_REFCLASS_DEBUG: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 |  | 
|  | 393 | /* | 
|  | 394 | * Storing to the Debug object causes the value stored to be | 
|  | 395 | * displayed and otherwise has no effect -- see ACPI Specification | 
|  | 396 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 397 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 398 | "**** Write to Debug Object: Object %p %s ****:\n\n", | 
|  | 399 | source_desc, | 
|  | 400 | acpi_ut_get_object_type_name(source_desc))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 402 | acpi_ex_do_debug_object(source_desc, 0, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | break; | 
|  | 404 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | default: | 
|  | 406 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 407 | ACPI_ERROR((AE_INFO, "Unknown Reference Class %2.2X", | 
|  | 408 | ref_desc->reference.class)); | 
| Bob Moore | 23d3e05 | 2008-09-28 15:00:47 +0800 | [diff] [blame] | 409 | ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_INFO); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 |  | 
|  | 411 | status = AE_AML_INTERNAL; | 
|  | 412 | break; | 
|  | 413 | } | 
|  | 414 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 415 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | } | 
|  | 417 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | /******************************************************************************* | 
|  | 419 | * | 
|  | 420 | * FUNCTION:    acpi_ex_store_object_to_index | 
|  | 421 | * | 
|  | 422 | * PARAMETERS:  *source_desc            - Value to be stored | 
|  | 423 | *              *dest_desc              - Named object to receive the value | 
|  | 424 | *              walk_state              - Current walk state | 
|  | 425 | * | 
|  | 426 | * RETURN:      Status | 
|  | 427 | * | 
|  | 428 | * DESCRIPTION: Store the object to indexed Buffer or Package element | 
|  | 429 | * | 
|  | 430 | ******************************************************************************/ | 
|  | 431 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 432 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, | 
|  | 434 | union acpi_operand_object *index_desc, | 
|  | 435 | struct acpi_walk_state *walk_state) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 437 | acpi_status status = AE_OK; | 
|  | 438 | union acpi_operand_object *obj_desc; | 
|  | 439 | union acpi_operand_object *new_desc; | 
|  | 440 | u8 value = 0; | 
|  | 441 | u32 i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 443 | ACPI_FUNCTION_TRACE(ex_store_object_to_index); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 |  | 
|  | 445 | /* | 
|  | 446 | * Destination must be a reference pointer, and | 
|  | 447 | * must point to either a buffer or a package | 
|  | 448 | */ | 
|  | 449 | switch (index_desc->reference.target_type) { | 
|  | 450 | case ACPI_TYPE_PACKAGE: | 
|  | 451 | /* | 
|  | 452 | * Storing to a package element. Copy the object and replace | 
|  | 453 | * any existing object with the new object. No implicit | 
|  | 454 | * conversion is performed. | 
|  | 455 | * | 
|  | 456 | * The object at *(index_desc->Reference.Where) is the | 
|  | 457 | * element within the package that is to be modified. | 
|  | 458 | * The parent package object is at index_desc->Reference.Object | 
|  | 459 | */ | 
|  | 460 | obj_desc = *(index_desc->reference.where); | 
|  | 461 |  | 
| Lin Ming | bc7a36a | 2008-04-10 19:06:42 +0400 | [diff] [blame] | 462 | if (ACPI_GET_OBJECT_TYPE(source_desc) == | 
|  | 463 | ACPI_TYPE_LOCAL_REFERENCE | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 464 | && source_desc->reference.class == ACPI_REFCLASS_TABLE) { | 
| Lin Ming | bc7a36a | 2008-04-10 19:06:42 +0400 | [diff] [blame] | 465 |  | 
|  | 466 | /* This is a DDBHandle, just add a reference to it */ | 
|  | 467 |  | 
|  | 468 | acpi_ut_add_reference(source_desc); | 
|  | 469 | new_desc = source_desc; | 
|  | 470 | } else { | 
|  | 471 | /* Normal object, copy it */ | 
|  | 472 |  | 
|  | 473 | status = | 
|  | 474 | acpi_ut_copy_iobject_to_iobject(source_desc, | 
|  | 475 | &new_desc, | 
|  | 476 | walk_state); | 
|  | 477 | if (ACPI_FAILURE(status)) { | 
|  | 478 | return_ACPI_STATUS(status); | 
|  | 479 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | } | 
|  | 481 |  | 
|  | 482 | if (obj_desc) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 483 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | /* Decrement reference count by the ref count of the parent package */ | 
|  | 485 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 486 | for (i = 0; i < ((union acpi_operand_object *) | 
|  | 487 | index_desc->reference.object)->common. | 
|  | 488 | reference_count; i++) { | 
|  | 489 | acpi_ut_remove_reference(obj_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | } | 
|  | 491 | } | 
|  | 492 |  | 
|  | 493 | *(index_desc->reference.where) = new_desc; | 
|  | 494 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 495 | /* Increment ref count by the ref count of the parent package-1 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 497 | for (i = 1; i < ((union acpi_operand_object *) | 
|  | 498 | index_desc->reference.object)->common. | 
|  | 499 | reference_count; i++) { | 
|  | 500 | acpi_ut_add_reference(new_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | } | 
|  | 502 |  | 
|  | 503 | break; | 
|  | 504 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | case ACPI_TYPE_BUFFER_FIELD: | 
|  | 506 |  | 
|  | 507 | /* | 
|  | 508 | * Store into a Buffer or String (not actually a real buffer_field) | 
|  | 509 | * at a location defined by an Index. | 
|  | 510 | * | 
|  | 511 | * The first 8-bit element of the source object is written to the | 
|  | 512 | * 8-bit Buffer location defined by the Index destination object, | 
|  | 513 | * according to the ACPI 2.0 specification. | 
|  | 514 | */ | 
|  | 515 |  | 
|  | 516 | /* | 
|  | 517 | * Make sure the target is a Buffer or String. An error should | 
|  | 518 | * not happen here, since the reference_object was constructed | 
|  | 519 | * by the INDEX_OP code. | 
|  | 520 | */ | 
|  | 521 | obj_desc = index_desc->reference.object; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 522 | if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) && | 
|  | 523 | (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) { | 
|  | 524 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } | 
|  | 526 |  | 
|  | 527 | /* | 
|  | 528 | * The assignment of the individual elements will be slightly | 
|  | 529 | * different for each source type. | 
|  | 530 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 531 | switch (ACPI_GET_OBJECT_TYPE(source_desc)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | case ACPI_TYPE_INTEGER: | 
|  | 533 |  | 
|  | 534 | /* Use the least-significant byte of the integer */ | 
|  | 535 |  | 
|  | 536 | value = (u8) (source_desc->integer.value); | 
|  | 537 | break; | 
|  | 538 |  | 
|  | 539 | case ACPI_TYPE_BUFFER: | 
|  | 540 | case ACPI_TYPE_STRING: | 
|  | 541 |  | 
|  | 542 | /* Note: Takes advantage of common string/buffer fields */ | 
|  | 543 |  | 
|  | 544 | value = source_desc->buffer.pointer[0]; | 
|  | 545 | break; | 
|  | 546 |  | 
|  | 547 | default: | 
|  | 548 |  | 
|  | 549 | /* All other types are invalid */ | 
|  | 550 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 551 | ACPI_ERROR((AE_INFO, | 
|  | 552 | "Source must be Integer/Buffer/String type, not %s", | 
|  | 553 | acpi_ut_get_object_type_name(source_desc))); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 554 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | } | 
|  | 556 |  | 
|  | 557 | /* Store the source value into the target buffer byte */ | 
|  | 558 |  | 
| Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 559 | obj_desc->buffer.pointer[index_desc->reference.value] = value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | break; | 
|  | 561 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | default: | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 563 | ACPI_ERROR((AE_INFO, "Target is not a Package or BufferField")); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | status = AE_AML_OPERAND_TYPE; | 
|  | 565 | break; | 
|  | 566 | } | 
|  | 567 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 568 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | } | 
|  | 570 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | /******************************************************************************* | 
|  | 572 | * | 
|  | 573 | * FUNCTION:    acpi_ex_store_object_to_node | 
|  | 574 | * | 
|  | 575 | * PARAMETERS:  source_desc             - Value to be stored | 
|  | 576 | *              Node                    - Named object to receive the value | 
|  | 577 | *              walk_state              - Current walk state | 
|  | 578 | *              implicit_conversion     - Perform implicit conversion (yes/no) | 
|  | 579 | * | 
|  | 580 | * RETURN:      Status | 
|  | 581 | * | 
|  | 582 | * DESCRIPTION: Store the object to the named object. | 
|  | 583 | * | 
|  | 584 | *              The Assignment of an object to a named object is handled here | 
|  | 585 | *              The value passed in will replace the current value (if any) | 
|  | 586 | *              with the input value. | 
|  | 587 | * | 
|  | 588 | *              When storing into an object the data is converted to the | 
|  | 589 | *              target object type then stored in the object.  This means | 
|  | 590 | *              that the target object type (for an initialized target) will | 
|  | 591 | *              not be changed by a store operation. | 
|  | 592 | * | 
|  | 593 | *              Assumes parameters are already validated. | 
|  | 594 | * | 
|  | 595 | ******************************************************************************/ | 
|  | 596 |  | 
|  | 597 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 598 | acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, | 
|  | 599 | struct acpi_namespace_node *node, | 
|  | 600 | struct acpi_walk_state *walk_state, | 
|  | 601 | u8 implicit_conversion) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 603 | acpi_status status = AE_OK; | 
|  | 604 | union acpi_operand_object *target_desc; | 
|  | 605 | union acpi_operand_object *new_desc; | 
|  | 606 | acpi_object_type target_type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 608 | ACPI_FUNCTION_TRACE_PTR(ex_store_object_to_node, source_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 610 | /* Get current type of the node, and object attached to Node */ | 
|  | 611 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 612 | target_type = acpi_ns_get_type(node); | 
|  | 613 | target_desc = acpi_ns_get_attached_object(node); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 615 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", | 
|  | 616 | source_desc, | 
|  | 617 | acpi_ut_get_object_type_name(source_desc), node, | 
|  | 618 | acpi_ut_get_type_name(target_type))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 |  | 
|  | 620 | /* | 
|  | 621 | * Resolve the source object to an actual value | 
|  | 622 | * (If it is a reference object) | 
|  | 623 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 624 | status = acpi_ex_resolve_object(&source_desc, target_type, walk_state); | 
|  | 625 | if (ACPI_FAILURE(status)) { | 
|  | 626 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | } | 
|  | 628 |  | 
|  | 629 | /* If no implicit conversion, drop into the default case below */ | 
|  | 630 |  | 
| Lin Ming | a3df4da | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 631 | if ((!implicit_conversion) || | 
|  | 632 | ((walk_state->opcode == AML_COPY_OP) && | 
|  | 633 | (target_type != ACPI_TYPE_LOCAL_REGION_FIELD) && | 
|  | 634 | (target_type != ACPI_TYPE_LOCAL_BANK_FIELD) && | 
|  | 635 | (target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) { | 
|  | 636 | /* | 
|  | 637 | * Force execution of default (no implicit conversion). Note: | 
|  | 638 | * copy_object does not perform an implicit conversion, as per the ACPI | 
|  | 639 | * spec -- except in case of region/bank/index fields -- because these | 
|  | 640 | * objects must retain their original type permanently. | 
|  | 641 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | target_type = ACPI_TYPE_ANY; | 
|  | 643 | } | 
|  | 644 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 645 | /* Do the actual store operation */ | 
|  | 646 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | switch (target_type) { | 
|  | 648 | case ACPI_TYPE_BUFFER_FIELD: | 
|  | 649 | case ACPI_TYPE_LOCAL_REGION_FIELD: | 
|  | 650 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 
|  | 651 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | 
|  | 652 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 653 | /* For fields, copy the source data to the target field. */ | 
|  | 654 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 655 | status = acpi_ex_write_data_to_field(source_desc, target_desc, | 
|  | 656 | &walk_state->result_obj); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | break; | 
|  | 658 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | case ACPI_TYPE_INTEGER: | 
|  | 660 | case ACPI_TYPE_STRING: | 
|  | 661 | case ACPI_TYPE_BUFFER: | 
|  | 662 |  | 
|  | 663 | /* | 
|  | 664 | * These target types are all of type Integer/String/Buffer, and | 
|  | 665 | * therefore support implicit conversion before the store. | 
|  | 666 | * | 
|  | 667 | * Copy and/or convert the source object to a new target object | 
|  | 668 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 669 | status = | 
|  | 670 | acpi_ex_store_object_to_object(source_desc, target_desc, | 
|  | 671 | &new_desc, walk_state); | 
|  | 672 | if (ACPI_FAILURE(status)) { | 
|  | 673 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | } | 
|  | 675 |  | 
|  | 676 | if (new_desc != target_desc) { | 
|  | 677 | /* | 
|  | 678 | * Store the new new_desc as the new value of the Name, and set | 
|  | 679 | * the Name's type to that of the value being stored in it. | 
|  | 680 | * source_desc reference count is incremented by attach_object. | 
|  | 681 | * | 
|  | 682 | * Note: This may change the type of the node if an explicit store | 
|  | 683 | * has been performed such that the node/object type has been | 
|  | 684 | * changed. | 
|  | 685 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 686 | status = | 
|  | 687 | acpi_ns_attach_object(node, new_desc, | 
|  | 688 | new_desc->common.type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 690 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 691 | "Store %s into %s via Convert/Attach\n", | 
|  | 692 | acpi_ut_get_object_type_name | 
|  | 693 | (source_desc), | 
|  | 694 | acpi_ut_get_object_type_name | 
|  | 695 | (new_desc))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | } | 
|  | 697 | break; | 
|  | 698 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | default: | 
|  | 700 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 701 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 702 | "Storing %s (%p) directly into node (%p) with no implicit conversion\n", | 
|  | 703 | acpi_ut_get_object_type_name(source_desc), | 
|  | 704 | source_desc, node)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 |  | 
|  | 706 | /* No conversions for all other types.  Just attach the source object */ | 
|  | 707 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 708 | status = acpi_ns_attach_object(node, source_desc, | 
|  | 709 | ACPI_GET_OBJECT_TYPE | 
|  | 710 | (source_desc)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | break; | 
|  | 712 | } | 
|  | 713 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 714 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | } |