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