aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exmisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/executer/exmisc.c')
-rw-r--r--drivers/acpi/executer/exmisc.c100
1 files changed, 53 insertions, 47 deletions
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index a3f4d72bedc9..5ad34566738c 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
48#include <acpi/amlresrc.h>
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exmisc") 51ACPI_MODULE_NAME("exmisc")
@@ -97,7 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
97 98
98 default: 99 default:
99 100
100 ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode)); 101 ACPI_REPORT_ERROR(("Unknown Reference opcode %X\n",
102 obj_desc->reference.opcode));
101 return_ACPI_STATUS(AE_AML_INTERNAL); 103 return_ACPI_STATUS(AE_AML_INTERNAL);
102 } 104 }
103 break; 105 break;
@@ -112,7 +114,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
112 114
113 default: 115 default:
114 116
115 ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); 117 ACPI_REPORT_ERROR(("Invalid descriptor type %X\n",
118 ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
116 return_ACPI_STATUS(AE_TYPE); 119 return_ACPI_STATUS(AE_TYPE);
117 } 120 }
118 121
@@ -157,48 +160,58 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
157 union acpi_operand_object **actual_return_desc, 160 union acpi_operand_object **actual_return_desc,
158 struct acpi_walk_state *walk_state) 161 struct acpi_walk_state *walk_state)
159{ 162{
163 acpi_status status;
160 union acpi_operand_object *return_desc; 164 union acpi_operand_object *return_desc;
161 u8 *new_buf; 165 u8 *new_buf;
162 u8 *end_tag1; 166 u8 *end_tag;
163 u8 *end_tag2; 167 acpi_size length0;
164 acpi_size length1; 168 acpi_size length1;
165 acpi_size length2;
166 169
167 ACPI_FUNCTION_TRACE("ex_concat_template"); 170 ACPI_FUNCTION_TRACE("ex_concat_template");
168 171
169 /* Find the end_tags in each resource template */ 172 /*
173 * Find the end_tag descriptor in each resource template.
174 * Note: returned pointers point TO the end_tag, not past it.
175 *
176 * Compute the length of each resource template
177 */
178 status = acpi_ut_get_resource_end_tag(operand0, &end_tag);
179 if (ACPI_FAILURE(status)) {
180 return_ACPI_STATUS(status);
181 }
182
183 length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer);
170 184
171 end_tag1 = acpi_ut_get_resource_end_tag(operand0); 185 status = acpi_ut_get_resource_end_tag(operand1, &end_tag);
172 end_tag2 = acpi_ut_get_resource_end_tag(operand1); 186 if (ACPI_FAILURE(status)) {
173 if (!end_tag1 || !end_tag2) { 187 return_ACPI_STATUS(status);
174 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
175 } 188 }
176 189
177 /* Compute the length of each part */ 190 /* Include the end_tag in the second template length */
178 191
179 length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); 192 length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer) +
180 length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */ 193 sizeof(struct aml_resource_end_tag);
181 194
182 /* Create a new buffer object for the result */ 195 /* Create a new buffer object for the result */
183 196
184 return_desc = acpi_ut_create_buffer_object(length1 + length2); 197 return_desc = acpi_ut_create_buffer_object(length0 + length1);
185 if (!return_desc) { 198 if (!return_desc) {
186 return_ACPI_STATUS(AE_NO_MEMORY); 199 return_ACPI_STATUS(AE_NO_MEMORY);
187 } 200 }
188 201
189 /* Copy the templates to the new descriptor */ 202 /*
190 203 * Copy the templates to the new buffer, 0 first, then 1 follows. One
204 * end_tag descriptor is copied from Operand1.
205 */
191 new_buf = return_desc->buffer.pointer; 206 new_buf = return_desc->buffer.pointer;
192 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); 207 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
193 ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); 208 ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
194 209
195 /* Compute the new checksum */ 210 /* Set the end_tag checksum to zero, means "ignore checksum" */
196 211
197 new_buf[return_desc->buffer.length - 1] = 212 new_buf[return_desc->buffer.length - 1] = 0;
198 acpi_ut_generate_checksum(return_desc->buffer.pointer,
199 (return_desc->buffer.length - 1));
200 213
201 /* Return the completed template descriptor */ 214 /* Return the completed resource template */
202 215
203 *actual_return_desc = return_desc; 216 *actual_return_desc = return_desc;
204 return_ACPI_STATUS(AE_OK); 217 return_ACPI_STATUS(AE_OK);
@@ -229,7 +242,6 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
229 union acpi_operand_object *return_desc; 242 union acpi_operand_object *return_desc;
230 char *new_buf; 243 char *new_buf;
231 acpi_status status; 244 acpi_status status;
232 acpi_size new_length;
233 245
234 ACPI_FUNCTION_TRACE("ex_do_concatenate"); 246 ACPI_FUNCTION_TRACE("ex_do_concatenate");
235 247
@@ -256,7 +268,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
256 break; 268 break;
257 269
258 default: 270 default:
259 ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", 271 ACPI_REPORT_ERROR(("Invalid object type: %X\n",
260 ACPI_GET_OBJECT_TYPE(operand0))); 272 ACPI_GET_OBJECT_TYPE(operand0)));
261 status = AE_AML_INTERNAL; 273 status = AE_AML_INTERNAL;
262 } 274 }
@@ -296,8 +308,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
296 308
297 /* Copy the first integer, LSB first */ 309 /* Copy the first integer, LSB first */
298 310
299 ACPI_MEMCPY(new_buf, 311 ACPI_MEMCPY(new_buf, &operand0->integer.value,
300 &operand0->integer.value,
301 acpi_gbl_integer_byte_width); 312 acpi_gbl_integer_byte_width);
302 313
303 /* Copy the second integer (LSB first) after the first */ 314 /* Copy the second integer (LSB first) after the first */
@@ -311,14 +322,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
311 322
312 /* Result of two Strings is a String */ 323 /* Result of two Strings is a String */
313 324
314 new_length = (acpi_size) operand0->string.length + 325 return_desc = acpi_ut_create_string_object((acpi_size)
315 (acpi_size) local_operand1->string.length; 326 (operand0->string.
316 if (new_length > ACPI_MAX_STRING_CONVERSION) { 327 length +
317 status = AE_AML_STRING_LIMIT; 328 local_operand1->
318 goto cleanup; 329 string.length));
319 }
320
321 return_desc = acpi_ut_create_string_object(new_length);
322 if (!return_desc) { 330 if (!return_desc) {
323 status = AE_NO_MEMORY; 331 status = AE_NO_MEMORY;
324 goto cleanup; 332 goto cleanup;
@@ -338,11 +346,10 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
338 /* Result of two Buffers is a Buffer */ 346 /* Result of two Buffers is a Buffer */
339 347
340 return_desc = acpi_ut_create_buffer_object((acpi_size) 348 return_desc = acpi_ut_create_buffer_object((acpi_size)
341 operand0->buffer. 349 (operand0->buffer.
342 length + 350 length +
343 (acpi_size) 351 local_operand1->
344 local_operand1-> 352 buffer.length));
345 buffer.length);
346 if (!return_desc) { 353 if (!return_desc) {
347 status = AE_NO_MEMORY; 354 status = AE_NO_MEMORY;
348 goto cleanup; 355 goto cleanup;
@@ -352,8 +359,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
352 359
353 /* Concatenate the buffers */ 360 /* Concatenate the buffers */
354 361
355 ACPI_MEMCPY(new_buf, 362 ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
356 operand0->buffer.pointer, operand0->buffer.length); 363 operand0->buffer.length);
357 ACPI_MEMCPY(new_buf + operand0->buffer.length, 364 ACPI_MEMCPY(new_buf + operand0->buffer.length,
358 local_operand1->buffer.pointer, 365 local_operand1->buffer.pointer,
359 local_operand1->buffer.length); 366 local_operand1->buffer.length);
@@ -363,7 +370,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
363 370
364 /* Invalid object type, should not happen here */ 371 /* Invalid object type, should not happen here */
365 372
366 ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n", 373 ACPI_REPORT_ERROR(("Invalid object type: %X\n",
367 ACPI_GET_OBJECT_TYPE(operand0))); 374 ACPI_GET_OBJECT_TYPE(operand0)));
368 status = AE_AML_INTERNAL; 375 status = AE_AML_INTERNAL;
369 goto cleanup; 376 goto cleanup;
@@ -625,9 +632,8 @@ acpi_ex_do_logical_op(u16 opcode,
625 632
626 /* Lexicographic compare: compare the data bytes */ 633 /* Lexicographic compare: compare the data bytes */
627 634
628 compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer, 635 compare = ACPI_MEMCMP(operand0->buffer.pointer,
629 (const char *)local_operand1->buffer. 636 local_operand1->buffer.pointer,
630 pointer,
631 (length0 > length1) ? length1 : length0); 637 (length0 > length1) ? length1 : length0);
632 638
633 switch (opcode) { 639 switch (opcode) {