Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
| 9 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 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/acinterp.h> |
| 47 | #include <acpi/amlcode.h> |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 48 | #include <acpi/amlresrc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #define _COMPONENT ACPI_EXECUTER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 51 | ACPI_MODULE_NAME("exmisc") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | /******************************************************************************* |
| 54 | * |
| 55 | * FUNCTION: acpi_ex_get_object_reference |
| 56 | * |
| 57 | * PARAMETERS: obj_desc - Create a reference to this object |
| 58 | * return_desc - Where to store the reference |
| 59 | * walk_state - Current state |
| 60 | * |
| 61 | * RETURN: Status |
| 62 | * |
| 63 | * DESCRIPTION: Obtain and return a "reference" to the target object |
| 64 | * Common code for the ref_of_op and the cond_ref_of_op. |
| 65 | * |
| 66 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 68 | acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, |
| 69 | union acpi_operand_object **return_desc, |
| 70 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 72 | union acpi_operand_object *reference_obj; |
| 73 | union acpi_operand_object *referenced_obj; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 75 | ACPI_FUNCTION_TRACE_PTR("ex_get_object_reference", obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | *return_desc = NULL; |
| 78 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 79 | switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | case ACPI_DESC_TYPE_OPERAND: |
| 81 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) { |
| 83 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | /* |
| 87 | * Must be a reference to a Local or Arg |
| 88 | */ |
| 89 | switch (obj_desc->reference.opcode) { |
| 90 | case AML_LOCAL_OP: |
| 91 | case AML_ARG_OP: |
| 92 | case AML_DEBUG_OP: |
| 93 | |
| 94 | /* The referenced object is the pseudo-node for the local/arg */ |
| 95 | |
| 96 | referenced_obj = obj_desc->reference.object; |
| 97 | break; |
| 98 | |
| 99 | default: |
| 100 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 101 | ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode)); |
| 102 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | break; |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | case ACPI_DESC_TYPE_NAMED: |
| 107 | |
| 108 | /* |
| 109 | * A named reference that has already been resolved to a Node |
| 110 | */ |
| 111 | referenced_obj = obj_desc; |
| 112 | break; |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | default: |
| 115 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); |
| 117 | return_ACPI_STATUS(AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | /* Create a new reference object */ |
| 121 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 122 | reference_obj = |
| 123 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | if (!reference_obj) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 125 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | reference_obj->reference.opcode = AML_REF_OF_OP; |
| 129 | reference_obj->reference.object = referenced_obj; |
| 130 | *return_desc = reference_obj; |
| 131 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 132 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 133 | "Object %p Type [%s], returning Reference %p\n", |
| 134 | obj_desc, acpi_ut_get_object_type_name(obj_desc), |
| 135 | *return_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | /******************************************************************************* |
| 141 | * |
| 142 | * FUNCTION: acpi_ex_concat_template |
| 143 | * |
| 144 | * PARAMETERS: Operand0 - First source object |
| 145 | * Operand1 - Second source object |
| 146 | * actual_return_desc - Where to place the return object |
| 147 | * walk_state - Current walk state |
| 148 | * |
| 149 | * RETURN: Status |
| 150 | * |
| 151 | * DESCRIPTION: Concatenate two resource templates |
| 152 | * |
| 153 | ******************************************************************************/ |
| 154 | |
| 155 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | acpi_ex_concat_template(union acpi_operand_object *operand0, |
| 157 | union acpi_operand_object *operand1, |
| 158 | union acpi_operand_object **actual_return_desc, |
| 159 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | { |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 161 | acpi_status status; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 162 | union acpi_operand_object *return_desc; |
| 163 | u8 *new_buf; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 164 | u8 *end_tag; |
| 165 | acpi_size length0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 166 | acpi_size length1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 168 | ACPI_FUNCTION_TRACE("ex_concat_template"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 170 | /* |
| 171 | * Find the end_tag descriptor in each resource template. |
| 172 | * Note: returned pointers point TO the end_tag, not past it. |
| 173 | * |
| 174 | * Compute the length of each resource template |
| 175 | */ |
| 176 | status = acpi_ut_get_resource_end_tag(operand0, &end_tag); |
| 177 | if (ACPI_FAILURE(status)) { |
| 178 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 181 | length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 183 | status = acpi_ut_get_resource_end_tag(operand1, &end_tag); |
| 184 | if (ACPI_FAILURE(status)) { |
| 185 | return_ACPI_STATUS(status); |
| 186 | } |
| 187 | |
| 188 | /* Include the end_tag in the second template length */ |
| 189 | |
| 190 | length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer) + |
| 191 | sizeof(struct aml_resource_end_tag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
| 193 | /* Create a new buffer object for the result */ |
| 194 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 195 | return_desc = acpi_ut_create_buffer_object(length0 + length1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | if (!return_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 197 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 200 | /* |
| 201 | * Copy the templates to the new buffer, 0 first, then 1 follows. One |
| 202 | * end_tag descriptor is copied from Operand1. |
| 203 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | new_buf = return_desc->buffer.pointer; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 205 | ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0); |
| 206 | ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
| 208 | /* Compute the new checksum */ |
| 209 | |
| 210 | new_buf[return_desc->buffer.length - 1] = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | acpi_ut_generate_checksum(return_desc->buffer.pointer, |
| 212 | (return_desc->buffer.length - 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame^] | 214 | /* Return the completed resource template */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 216 | *actual_return_desc = return_desc; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 217 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | /******************************************************************************* |
| 221 | * |
| 222 | * FUNCTION: acpi_ex_do_concatenate |
| 223 | * |
| 224 | * PARAMETERS: Operand0 - First source object |
| 225 | * Operand1 - Second source object |
| 226 | * actual_return_desc - Where to place the return object |
| 227 | * walk_state - Current walk state |
| 228 | * |
| 229 | * RETURN: Status |
| 230 | * |
| 231 | * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. |
| 232 | * |
| 233 | ******************************************************************************/ |
| 234 | |
| 235 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 236 | acpi_ex_do_concatenate(union acpi_operand_object *operand0, |
| 237 | union acpi_operand_object *operand1, |
| 238 | union acpi_operand_object **actual_return_desc, |
| 239 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 241 | union acpi_operand_object *local_operand1 = operand1; |
| 242 | union acpi_operand_object *return_desc; |
| 243 | char *new_buf; |
| 244 | acpi_status status; |
| 245 | acpi_size new_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 247 | ACPI_FUNCTION_TRACE("ex_do_concatenate"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | /* |
| 250 | * Convert the second operand if necessary. The first operand |
| 251 | * determines the type of the second operand, (See the Data Types |
| 252 | * section of the ACPI specification.) Both object types are |
| 253 | * guaranteed to be either Integer/String/Buffer by the operand |
| 254 | * resolution mechanism. |
| 255 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 256 | switch (ACPI_GET_OBJECT_TYPE(operand0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | case ACPI_TYPE_INTEGER: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 258 | status = |
| 259 | acpi_ex_convert_to_integer(operand1, &local_operand1, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | break; |
| 261 | |
| 262 | case ACPI_TYPE_STRING: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 263 | status = acpi_ex_convert_to_string(operand1, &local_operand1, |
| 264 | ACPI_IMPLICIT_CONVERT_HEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | break; |
| 266 | |
| 267 | case ACPI_TYPE_BUFFER: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | status = acpi_ex_convert_to_buffer(operand1, &local_operand1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | break; |
| 270 | |
| 271 | default: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", |
| 273 | ACPI_GET_OBJECT_TYPE(operand0))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | status = AE_AML_INTERNAL; |
| 275 | } |
| 276 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 277 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | goto cleanup; |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * Both operands are now known to be the same object type |
| 283 | * (Both are Integer, String, or Buffer), and we can now perform the |
| 284 | * concatenation. |
| 285 | */ |
| 286 | |
| 287 | /* |
| 288 | * There are three cases to handle: |
| 289 | * |
| 290 | * 1) Two Integers concatenated to produce a new Buffer |
| 291 | * 2) Two Strings concatenated to produce a new String |
| 292 | * 3) Two Buffers concatenated to produce a new Buffer |
| 293 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | switch (ACPI_GET_OBJECT_TYPE(operand0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | case ACPI_TYPE_INTEGER: |
| 296 | |
| 297 | /* Result of two Integers is a Buffer */ |
| 298 | /* Need enough buffer space for two integers */ |
| 299 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | return_desc = acpi_ut_create_buffer_object((acpi_size) |
| 301 | ACPI_MUL_2 |
| 302 | (acpi_gbl_integer_byte_width)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | if (!return_desc) { |
| 304 | status = AE_NO_MEMORY; |
| 305 | goto cleanup; |
| 306 | } |
| 307 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | new_buf = (char *)return_desc->buffer.pointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
| 310 | /* Copy the first integer, LSB first */ |
| 311 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 312 | ACPI_MEMCPY(new_buf, |
| 313 | &operand0->integer.value, |
| 314 | acpi_gbl_integer_byte_width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | /* Copy the second integer (LSB first) after the first */ |
| 317 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 318 | ACPI_MEMCPY(new_buf + acpi_gbl_integer_byte_width, |
| 319 | &local_operand1->integer.value, |
| 320 | acpi_gbl_integer_byte_width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | break; |
| 322 | |
| 323 | case ACPI_TYPE_STRING: |
| 324 | |
| 325 | /* Result of two Strings is a String */ |
| 326 | |
| 327 | new_length = (acpi_size) operand0->string.length + |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 328 | (acpi_size) local_operand1->string.length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | if (new_length > ACPI_MAX_STRING_CONVERSION) { |
| 330 | status = AE_AML_STRING_LIMIT; |
| 331 | goto cleanup; |
| 332 | } |
| 333 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 334 | return_desc = acpi_ut_create_string_object(new_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (!return_desc) { |
| 336 | status = AE_NO_MEMORY; |
| 337 | goto cleanup; |
| 338 | } |
| 339 | |
| 340 | new_buf = return_desc->string.pointer; |
| 341 | |
| 342 | /* Concatenate the strings */ |
| 343 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 344 | ACPI_STRCPY(new_buf, operand0->string.pointer); |
| 345 | ACPI_STRCPY(new_buf + operand0->string.length, |
| 346 | local_operand1->string.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | break; |
| 348 | |
| 349 | case ACPI_TYPE_BUFFER: |
| 350 | |
| 351 | /* Result of two Buffers is a Buffer */ |
| 352 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | return_desc = acpi_ut_create_buffer_object((acpi_size) |
| 354 | operand0->buffer. |
| 355 | length + |
| 356 | (acpi_size) |
| 357 | local_operand1-> |
| 358 | buffer.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | if (!return_desc) { |
| 360 | status = AE_NO_MEMORY; |
| 361 | goto cleanup; |
| 362 | } |
| 363 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 364 | new_buf = (char *)return_desc->buffer.pointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
| 366 | /* Concatenate the buffers */ |
| 367 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | ACPI_MEMCPY(new_buf, |
| 369 | operand0->buffer.pointer, operand0->buffer.length); |
| 370 | ACPI_MEMCPY(new_buf + operand0->buffer.length, |
| 371 | local_operand1->buffer.pointer, |
| 372 | local_operand1->buffer.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | break; |
| 374 | |
| 375 | default: |
| 376 | |
| 377 | /* Invalid object type, should not happen here */ |
| 378 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 379 | ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n", |
| 380 | ACPI_GET_OBJECT_TYPE(operand0))); |
| 381 | status = AE_AML_INTERNAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | goto cleanup; |
| 383 | } |
| 384 | |
| 385 | *actual_return_desc = return_desc; |
| 386 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 387 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | if (local_operand1 != operand1) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 389 | acpi_ut_remove_reference(local_operand1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 391 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | /******************************************************************************* |
| 395 | * |
| 396 | * FUNCTION: acpi_ex_do_math_op |
| 397 | * |
| 398 | * PARAMETERS: Opcode - AML opcode |
| 399 | * Integer0 - Integer operand #0 |
| 400 | * Integer1 - Integer operand #1 |
| 401 | * |
| 402 | * RETURN: Integer result of the operation |
| 403 | * |
| 404 | * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the |
| 405 | * math functions here is to prevent a lot of pointer dereferencing |
| 406 | * to obtain the operands. |
| 407 | * |
| 408 | ******************************************************************************/ |
| 409 | |
| 410 | acpi_integer |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | { |
| 413 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 414 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
| 416 | switch (opcode) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
| 419 | return (integer0 + integer1); |
| 420 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 421 | case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | |
| 423 | return (integer0 & integer1); |
| 424 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
| 427 | return (~(integer0 & integer1)); |
| 428 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
| 431 | return (integer0 | integer1); |
| 432 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | |
| 435 | return (~(integer0 | integer1)); |
| 436 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 437 | case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
| 439 | return (integer0 ^ integer1); |
| 440 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 441 | case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | |
| 443 | return (integer0 * integer1); |
| 444 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 445 | case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | |
| 447 | return (integer0 << integer1); |
| 448 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
| 451 | return (integer0 >> integer1); |
| 452 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 453 | case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
| 455 | return (integer0 - integer1); |
| 456 | |
| 457 | default: |
| 458 | |
| 459 | return (0); |
| 460 | } |
| 461 | } |
| 462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | /******************************************************************************* |
| 464 | * |
| 465 | * FUNCTION: acpi_ex_do_logical_numeric_op |
| 466 | * |
| 467 | * PARAMETERS: Opcode - AML opcode |
| 468 | * Integer0 - Integer operand #0 |
| 469 | * Integer1 - Integer operand #1 |
| 470 | * logical_result - TRUE/FALSE result of the operation |
| 471 | * |
| 472 | * RETURN: Status |
| 473 | * |
| 474 | * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric |
| 475 | * operators (LAnd and LOr), both operands must be integers. |
| 476 | * |
| 477 | * Note: cleanest machine code seems to be produced by the code |
| 478 | * below, rather than using statements of the form: |
| 479 | * Result = (Integer0 && Integer1); |
| 480 | * |
| 481 | ******************************************************************************/ |
| 482 | |
| 483 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 484 | acpi_ex_do_logical_numeric_op(u16 opcode, |
| 485 | acpi_integer integer0, |
| 486 | acpi_integer integer1, u8 * logical_result) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 488 | acpi_status status = AE_OK; |
| 489 | u8 local_result = FALSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | ACPI_FUNCTION_TRACE("ex_do_logical_numeric_op"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
| 493 | switch (opcode) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 494 | case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | |
| 496 | if (integer0 && integer1) { |
| 497 | local_result = TRUE; |
| 498 | } |
| 499 | break; |
| 500 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 501 | case AML_LOR_OP: /* LOr (Integer0, Integer1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | |
| 503 | if (integer0 || integer1) { |
| 504 | local_result = TRUE; |
| 505 | } |
| 506 | break; |
| 507 | |
| 508 | default: |
| 509 | status = AE_AML_INTERNAL; |
| 510 | break; |
| 511 | } |
| 512 | |
| 513 | /* Return the logical result and status */ |
| 514 | |
| 515 | *logical_result = local_result; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 516 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | /******************************************************************************* |
| 520 | * |
| 521 | * FUNCTION: acpi_ex_do_logical_op |
| 522 | * |
| 523 | * PARAMETERS: Opcode - AML opcode |
| 524 | * Operand0 - operand #0 |
| 525 | * Operand1 - operand #1 |
| 526 | * logical_result - TRUE/FALSE result of the operation |
| 527 | * |
| 528 | * RETURN: Status |
| 529 | * |
| 530 | * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the |
| 531 | * functions here is to prevent a lot of pointer dereferencing |
| 532 | * to obtain the operands and to simplify the generation of the |
| 533 | * logical value. For the Numeric operators (LAnd and LOr), both |
| 534 | * operands must be integers. For the other logical operators, |
| 535 | * operands can be any combination of Integer/String/Buffer. The |
| 536 | * first operand determines the type to which the second operand |
| 537 | * will be converted. |
| 538 | * |
| 539 | * Note: cleanest machine code seems to be produced by the code |
| 540 | * below, rather than using statements of the form: |
| 541 | * Result = (Operand0 == Operand1); |
| 542 | * |
| 543 | ******************************************************************************/ |
| 544 | |
| 545 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 546 | acpi_ex_do_logical_op(u16 opcode, |
| 547 | union acpi_operand_object *operand0, |
| 548 | union acpi_operand_object *operand1, u8 * logical_result) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 550 | union acpi_operand_object *local_operand1 = operand1; |
| 551 | acpi_integer integer0; |
| 552 | acpi_integer integer1; |
| 553 | u32 length0; |
| 554 | u32 length1; |
| 555 | acpi_status status = AE_OK; |
| 556 | u8 local_result = FALSE; |
| 557 | int compare; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 559 | ACPI_FUNCTION_TRACE("ex_do_logical_op"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | |
| 561 | /* |
| 562 | * Convert the second operand if necessary. The first operand |
| 563 | * determines the type of the second operand, (See the Data Types |
| 564 | * section of the ACPI 3.0+ specification.) Both object types are |
| 565 | * guaranteed to be either Integer/String/Buffer by the operand |
| 566 | * resolution mechanism. |
| 567 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 568 | switch (ACPI_GET_OBJECT_TYPE(operand0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | case ACPI_TYPE_INTEGER: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 570 | status = |
| 571 | acpi_ex_convert_to_integer(operand1, &local_operand1, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | break; |
| 573 | |
| 574 | case ACPI_TYPE_STRING: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 575 | status = acpi_ex_convert_to_string(operand1, &local_operand1, |
| 576 | ACPI_IMPLICIT_CONVERT_HEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | break; |
| 578 | |
| 579 | case ACPI_TYPE_BUFFER: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 580 | status = acpi_ex_convert_to_buffer(operand1, &local_operand1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | break; |
| 582 | |
| 583 | default: |
| 584 | status = AE_AML_INTERNAL; |
| 585 | break; |
| 586 | } |
| 587 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 588 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | goto cleanup; |
| 590 | } |
| 591 | |
| 592 | /* |
| 593 | * Two cases: 1) Both Integers, 2) Both Strings or Buffers |
| 594 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 595 | if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | /* |
| 597 | * 1) Both operands are of type integer |
| 598 | * Note: local_operand1 may have changed above |
| 599 | */ |
| 600 | integer0 = operand0->integer.value; |
| 601 | integer1 = local_operand1->integer.value; |
| 602 | |
| 603 | switch (opcode) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 604 | case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
| 606 | if (integer0 == integer1) { |
| 607 | local_result = TRUE; |
| 608 | } |
| 609 | break; |
| 610 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 611 | case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | |
| 613 | if (integer0 > integer1) { |
| 614 | local_result = TRUE; |
| 615 | } |
| 616 | break; |
| 617 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 618 | case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
| 620 | if (integer0 < integer1) { |
| 621 | local_result = TRUE; |
| 622 | } |
| 623 | break; |
| 624 | |
| 625 | default: |
| 626 | status = AE_AML_INTERNAL; |
| 627 | break; |
| 628 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 629 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | /* |
| 631 | * 2) Both operands are Strings or both are Buffers |
| 632 | * Note: Code below takes advantage of common Buffer/String |
| 633 | * object fields. local_operand1 may have changed above. Use |
| 634 | * memcmp to handle nulls in buffers. |
| 635 | */ |
| 636 | length0 = operand0->buffer.length; |
| 637 | length1 = local_operand1->buffer.length; |
| 638 | |
| 639 | /* Lexicographic compare: compare the data bytes */ |
| 640 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 641 | compare = ACPI_MEMCMP(operand0->buffer.pointer, |
| 642 | local_operand1->buffer.pointer, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 643 | (length0 > length1) ? length1 : length0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | |
| 645 | switch (opcode) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 646 | case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | |
| 648 | /* Length and all bytes must be equal */ |
| 649 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 650 | if ((length0 == length1) && (compare == 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | /* Length and all bytes match ==> TRUE */ |
| 652 | |
| 653 | local_result = TRUE; |
| 654 | } |
| 655 | break; |
| 656 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 657 | case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
| 659 | if (compare > 0) { |
| 660 | local_result = TRUE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 661 | goto cleanup; /* TRUE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | } |
| 663 | if (compare < 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 664 | goto cleanup; /* FALSE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | /* Bytes match (to shortest length), compare lengths */ |
| 668 | |
| 669 | if (length0 > length1) { |
| 670 | local_result = TRUE; |
| 671 | } |
| 672 | break; |
| 673 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 674 | case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
| 676 | if (compare > 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 677 | goto cleanup; /* FALSE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | } |
| 679 | if (compare < 0) { |
| 680 | local_result = TRUE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 681 | goto cleanup; /* TRUE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | /* Bytes match (to shortest length), compare lengths */ |
| 685 | |
| 686 | if (length0 < length1) { |
| 687 | local_result = TRUE; |
| 688 | } |
| 689 | break; |
| 690 | |
| 691 | default: |
| 692 | status = AE_AML_INTERNAL; |
| 693 | break; |
| 694 | } |
| 695 | } |
| 696 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 697 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | |
| 699 | /* New object was created if implicit conversion performed - delete */ |
| 700 | |
| 701 | if (local_operand1 != operand1) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 702 | acpi_ut_remove_reference(local_operand1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | /* Return the logical result and status */ |
| 706 | |
| 707 | *logical_result = local_result; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 708 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | } |