Deleted Added
full compact
exmisc.c (151937) exmisc.c (167802)
1
2/******************************************************************************
3 *
4 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
1
2/******************************************************************************
3 *
4 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
5 * $Revision: 1.132 $
5 * $Revision: 1.144 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.

--- 94 unchanged lines hidden (view full) ---

116 *
117 *****************************************************************************/
118
119#define __EXMISC_C__
120
121#include <contrib/dev/acpica/acpi.h>
122#include <contrib/dev/acpica/acinterp.h>
123#include <contrib/dev/acpica/amlcode.h>
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.

--- 94 unchanged lines hidden (view full) ---

116 *
117 *****************************************************************************/
118
119#define __EXMISC_C__
120
121#include <contrib/dev/acpica/acpi.h>
122#include <contrib/dev/acpica/acinterp.h>
123#include <contrib/dev/acpica/amlcode.h>
124#include <contrib/dev/acpica/amlresrc.h>
124
125
126#define _COMPONENT ACPI_EXECUTER
127 ACPI_MODULE_NAME ("exmisc")
128
129
130/*******************************************************************************
131 *

--- 15 unchanged lines hidden (view full) ---

147 ACPI_OPERAND_OBJECT *ObjDesc,
148 ACPI_OPERAND_OBJECT **ReturnDesc,
149 ACPI_WALK_STATE *WalkState)
150{
151 ACPI_OPERAND_OBJECT *ReferenceObj;
152 ACPI_OPERAND_OBJECT *ReferencedObj;
153
154
125
126
127#define _COMPONENT ACPI_EXECUTER
128 ACPI_MODULE_NAME ("exmisc")
129
130
131/*******************************************************************************
132 *

--- 15 unchanged lines hidden (view full) ---

148 ACPI_OPERAND_OBJECT *ObjDesc,
149 ACPI_OPERAND_OBJECT **ReturnDesc,
150 ACPI_WALK_STATE *WalkState)
151{
152 ACPI_OPERAND_OBJECT *ReferenceObj;
153 ACPI_OPERAND_OBJECT *ReferencedObj;
154
155
155 ACPI_FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc);
156 ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
156
157
158 *ReturnDesc = NULL;
159
160 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
161 {
162 case ACPI_DESC_TYPE_OPERAND:
163

--- 13 unchanged lines hidden (view full) ---

177
178 /* The referenced object is the pseudo-node for the local/arg */
179
180 ReferencedObj = ObjDesc->Reference.Object;
181 break;
182
183 default:
184
157
158
159 *ReturnDesc = NULL;
160
161 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
162 {
163 case ACPI_DESC_TYPE_OPERAND:
164

--- 13 unchanged lines hidden (view full) ---

178
179 /* The referenced object is the pseudo-node for the local/arg */
180
181 ReferencedObj = ObjDesc->Reference.Object;
182 break;
183
184 default:
185
185 ACPI_REPORT_ERROR (("Unknown Reference opcode in GetReference %X\n",
186 ACPI_ERROR ((AE_INFO, "Unknown Reference opcode %X",
186 ObjDesc->Reference.Opcode));
187 return_ACPI_STATUS (AE_AML_INTERNAL);
188 }
189 break;
190
191
192 case ACPI_DESC_TYPE_NAMED:
193
194 /*
195 * A named reference that has already been resolved to a Node
196 */
197 ReferencedObj = ObjDesc;
198 break;
199
200
201 default:
202
187 ObjDesc->Reference.Opcode));
188 return_ACPI_STATUS (AE_AML_INTERNAL);
189 }
190 break;
191
192
193 case ACPI_DESC_TYPE_NAMED:
194
195 /*
196 * A named reference that has already been resolved to a Node
197 */
198 ReferencedObj = ObjDesc;
199 break;
200
201
202 default:
203
203 ACPI_REPORT_ERROR (("Invalid descriptor type in GetReference: %X\n",
204 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
204 ACPI_ERROR ((AE_INFO, "Invalid descriptor type %X",
205 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
205 return_ACPI_STATUS (AE_TYPE);
206 }
207
208
209 /* Create a new reference object */
210
211 ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
212 if (!ReferenceObj)

--- 30 unchanged lines hidden (view full) ---

243
244ACPI_STATUS
245AcpiExConcatTemplate (
246 ACPI_OPERAND_OBJECT *Operand0,
247 ACPI_OPERAND_OBJECT *Operand1,
248 ACPI_OPERAND_OBJECT **ActualReturnDesc,
249 ACPI_WALK_STATE *WalkState)
250{
206 return_ACPI_STATUS (AE_TYPE);
207 }
208
209
210 /* Create a new reference object */
211
212 ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
213 if (!ReferenceObj)

--- 30 unchanged lines hidden (view full) ---

244
245ACPI_STATUS
246AcpiExConcatTemplate (
247 ACPI_OPERAND_OBJECT *Operand0,
248 ACPI_OPERAND_OBJECT *Operand1,
249 ACPI_OPERAND_OBJECT **ActualReturnDesc,
250 ACPI_WALK_STATE *WalkState)
251{
252 ACPI_STATUS Status;
251 ACPI_OPERAND_OBJECT *ReturnDesc;
252 UINT8 *NewBuf;
253 ACPI_OPERAND_OBJECT *ReturnDesc;
254 UINT8 *NewBuf;
253 UINT8 *EndTag1;
254 UINT8 *EndTag2;
255 UINT8 *EndTag;
256 ACPI_SIZE Length0;
255 ACPI_SIZE Length1;
257 ACPI_SIZE Length1;
256 ACPI_SIZE Length2;
258 ACPI_SIZE NewLength;
257
258
259
260
259 ACPI_FUNCTION_TRACE ("ExConcatTemplate");
261 ACPI_FUNCTION_TRACE (ExConcatTemplate);
260
261
262
263
262 /* Find the EndTags in each resource template */
264 /*
265 * Find the EndTag descriptor in each resource template.
266 * Note1: returned pointers point TO the EndTag, not past it.
267 * Note2: zero-length buffers are allowed; treated like one EndTag
268 */
263
269
264 EndTag1 = AcpiUtGetResourceEndTag (Operand0);
265 EndTag2 = AcpiUtGetResourceEndTag (Operand1);
266 if (!EndTag1 || !EndTag2)
270 /* Get the length of the first resource template */
271
272 Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
273 if (ACPI_FAILURE (Status))
267 {
274 {
268 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
275 return_ACPI_STATUS (Status);
269 }
270
276 }
277
271 /* Compute the length of each part */
278 Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
272
279
273 Length1 = ACPI_PTR_DIFF (EndTag1, Operand0->Buffer.Pointer);
274 Length2 = ACPI_PTR_DIFF (EndTag2, Operand1->Buffer.Pointer) +
275 2; /* Size of END_TAG */
280 /* Get the length of the second resource template */
276
281
277 /* Create a new buffer object for the result */
282 Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
283 if (ACPI_FAILURE (Status))
284 {
285 return_ACPI_STATUS (Status);
286 }
278
287
279 ReturnDesc = AcpiUtCreateBufferObject (Length1 + Length2);
288 Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
289
290 /* Combine both lengths, minimum size will be 2 for EndTag */
291
292 NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
293
294 /* Create a new buffer object for the result (with one EndTag) */
295
296 ReturnDesc = AcpiUtCreateBufferObject (NewLength);
280 if (!ReturnDesc)
281 {
282 return_ACPI_STATUS (AE_NO_MEMORY);
283 }
284
297 if (!ReturnDesc)
298 {
299 return_ACPI_STATUS (AE_NO_MEMORY);
300 }
301
285 /* Copy the templates to the new descriptor */
286
302 /*
303 * Copy the templates to the new buffer, 0 first, then 1 follows. One
304 * EndTag descriptor is copied from Operand1.
305 */
287 NewBuf = ReturnDesc->Buffer.Pointer;
306 NewBuf = ReturnDesc->Buffer.Pointer;
288 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length1);
289 ACPI_MEMCPY (NewBuf + Length1, Operand1->Buffer.Pointer, Length2);
307 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
308 ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
290
309
291 /* Compute the new checksum */
310 /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
292
311
293 NewBuf[ReturnDesc->Buffer.Length - 1] =
294 AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer,
295 (ReturnDesc->Buffer.Length - 1));
312 NewBuf[NewLength - 1] = 0;
313 NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
296
314
297 /* Return the completed template descriptor */
315 /* Return the completed resource template */
298
299 *ActualReturnDesc = ReturnDesc;
300 return_ACPI_STATUS (AE_OK);
301}
302
303
304/*******************************************************************************
305 *

--- 16 unchanged lines hidden (view full) ---

322 ACPI_OPERAND_OBJECT *Operand1,
323 ACPI_OPERAND_OBJECT **ActualReturnDesc,
324 ACPI_WALK_STATE *WalkState)
325{
326 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
327 ACPI_OPERAND_OBJECT *ReturnDesc;
328 char *NewBuf;
329 ACPI_STATUS Status;
316
317 *ActualReturnDesc = ReturnDesc;
318 return_ACPI_STATUS (AE_OK);
319}
320
321
322/*******************************************************************************
323 *

--- 16 unchanged lines hidden (view full) ---

340 ACPI_OPERAND_OBJECT *Operand1,
341 ACPI_OPERAND_OBJECT **ActualReturnDesc,
342 ACPI_WALK_STATE *WalkState)
343{
344 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
345 ACPI_OPERAND_OBJECT *ReturnDesc;
346 char *NewBuf;
347 ACPI_STATUS Status;
330 ACPI_SIZE NewLength;
331
332
348
349
333 ACPI_FUNCTION_TRACE ("ExDoConcatenate");
350 ACPI_FUNCTION_TRACE (ExDoConcatenate);
334
335
336 /*
337 * Convert the second operand if necessary. The first operand
338 * determines the type of the second operand, (See the Data Types
339 * section of the ACPI specification.) Both object types are
340 * guaranteed to be either Integer/String/Buffer by the operand
341 * resolution mechanism.

--- 9 unchanged lines hidden (view full) ---

351 ACPI_IMPLICIT_CONVERT_HEX);
352 break;
353
354 case ACPI_TYPE_BUFFER:
355 Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
356 break;
357
358 default:
351
352
353 /*
354 * Convert the second operand if necessary. The first operand
355 * determines the type of the second operand, (See the Data Types
356 * section of the ACPI specification.) Both object types are
357 * guaranteed to be either Integer/String/Buffer by the operand
358 * resolution mechanism.

--- 9 unchanged lines hidden (view full) ---

368 ACPI_IMPLICIT_CONVERT_HEX);
369 break;
370
371 case ACPI_TYPE_BUFFER:
372 Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
373 break;
374
375 default:
359 ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
360 ACPI_GET_OBJECT_TYPE (Operand0)));
376 ACPI_ERROR ((AE_INFO, "Invalid object type: %X",
377 ACPI_GET_OBJECT_TYPE (Operand0)));
361 Status = AE_AML_INTERNAL;
362 }
363
364 if (ACPI_FAILURE (Status))
365 {
366 goto Cleanup;
367 }
368

--- 24 unchanged lines hidden (view full) ---

393 Status = AE_NO_MEMORY;
394 goto Cleanup;
395 }
396
397 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
398
399 /* Copy the first integer, LSB first */
400
378 Status = AE_AML_INTERNAL;
379 }
380
381 if (ACPI_FAILURE (Status))
382 {
383 goto Cleanup;
384 }
385

--- 24 unchanged lines hidden (view full) ---

410 Status = AE_NO_MEMORY;
411 goto Cleanup;
412 }
413
414 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
415
416 /* Copy the first integer, LSB first */
417
401 ACPI_MEMCPY (NewBuf,
402 &Operand0->Integer.Value,
418 ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
403 AcpiGbl_IntegerByteWidth);
404
405 /* Copy the second integer (LSB first) after the first */
406
407 ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
408 &LocalOperand1->Integer.Value,
409 AcpiGbl_IntegerByteWidth);
410 break;
411
412 case ACPI_TYPE_STRING:
413
414 /* Result of two Strings is a String */
415
419 AcpiGbl_IntegerByteWidth);
420
421 /* Copy the second integer (LSB first) after the first */
422
423 ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
424 &LocalOperand1->Integer.Value,
425 AcpiGbl_IntegerByteWidth);
426 break;
427
428 case ACPI_TYPE_STRING:
429
430 /* Result of two Strings is a String */
431
416 NewLength = (ACPI_SIZE) Operand0->String.Length +
417 (ACPI_SIZE) LocalOperand1->String.Length;
418 if (NewLength > ACPI_MAX_STRING_CONVERSION)
419 {
420 Status = AE_AML_STRING_LIMIT;
421 goto Cleanup;
422 }
423
424 ReturnDesc = AcpiUtCreateStringObject (NewLength);
432 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE)
433 (Operand0->String.Length +
434 LocalOperand1->String.Length));
425 if (!ReturnDesc)
426 {
427 Status = AE_NO_MEMORY;
428 goto Cleanup;
429 }
430
431 NewBuf = ReturnDesc->String.Pointer;
432
433 /* Concatenate the strings */
434
435 if (!ReturnDesc)
436 {
437 Status = AE_NO_MEMORY;
438 goto Cleanup;
439 }
440
441 NewBuf = ReturnDesc->String.Pointer;
442
443 /* Concatenate the strings */
444
435 ACPI_STRCPY (NewBuf,
436 Operand0->String.Pointer);
445 ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
437 ACPI_STRCPY (NewBuf + Operand0->String.Length,
438 LocalOperand1->String.Pointer);
439 break;
440
441 case ACPI_TYPE_BUFFER:
442
443 /* Result of two Buffers is a Buffer */
444
446 ACPI_STRCPY (NewBuf + Operand0->String.Length,
447 LocalOperand1->String.Pointer);
448 break;
449
450 case ACPI_TYPE_BUFFER:
451
452 /* Result of two Buffers is a Buffer */
453
445 ReturnDesc = AcpiUtCreateBufferObject (
446 (ACPI_SIZE) Operand0->Buffer.Length +
447 (ACPI_SIZE) LocalOperand1->Buffer.Length);
454 ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
455 (Operand0->Buffer.Length +
456 LocalOperand1->Buffer.Length));
448 if (!ReturnDesc)
449 {
450 Status = AE_NO_MEMORY;
451 goto Cleanup;
452 }
453
454 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
455
456 /* Concatenate the buffers */
457
457 if (!ReturnDesc)
458 {
459 Status = AE_NO_MEMORY;
460 goto Cleanup;
461 }
462
463 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
464
465 /* Concatenate the buffers */
466
458 ACPI_MEMCPY (NewBuf,
459 Operand0->Buffer.Pointer,
467 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
460 Operand0->Buffer.Length);
461 ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
462 LocalOperand1->Buffer.Pointer,
463 LocalOperand1->Buffer.Length);
464 break;
465
466 default:
467
468 /* Invalid object type, should not happen here */
469
468 Operand0->Buffer.Length);
469 ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
470 LocalOperand1->Buffer.Pointer,
471 LocalOperand1->Buffer.Length);
472 break;
473
474 default:
475
476 /* Invalid object type, should not happen here */
477
470 ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n",
471 ACPI_GET_OBJECT_TYPE (Operand0)));
478 ACPI_ERROR ((AE_INFO, "Invalid object type: %X",
479 ACPI_GET_OBJECT_TYPE (Operand0)));
472 Status =AE_AML_INTERNAL;
473 goto Cleanup;
474 }
475
476 *ActualReturnDesc = ReturnDesc;
477
478Cleanup:
479 if (LocalOperand1 != Operand1)

--- 64 unchanged lines hidden (view full) ---

544
545 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
546
547 return (Integer0 * Integer1);
548
549
550 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
551
480 Status =AE_AML_INTERNAL;
481 goto Cleanup;
482 }
483
484 *ActualReturnDesc = ReturnDesc;
485
486Cleanup:
487 if (LocalOperand1 != Operand1)

--- 64 unchanged lines hidden (view full) ---

552
553 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
554
555 return (Integer0 * Integer1);
556
557
558 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
559
560 /*
561 * We need to check if the shiftcount is larger than the integer bit
562 * width since the behavior of this is not well-defined in the C language.
563 */
564 if (Integer1 >= AcpiGbl_IntegerBitWidth)
565 {
566 return (0);
567 }
552 return (Integer0 << Integer1);
553
554
555 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
556
568 return (Integer0 << Integer1);
569
570
571 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
572
573 /*
574 * We need to check if the shiftcount is larger than the integer bit
575 * width since the behavior of this is not well-defined in the C language.
576 */
577 if (Integer1 >= AcpiGbl_IntegerBitWidth)
578 {
579 return (0);
580 }
557 return (Integer0 >> Integer1);
558
559
560 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
561
562 return (Integer0 - Integer1);
563
564 default:

--- 29 unchanged lines hidden (view full) ---

594 ACPI_INTEGER Integer0,
595 ACPI_INTEGER Integer1,
596 BOOLEAN *LogicalResult)
597{
598 ACPI_STATUS Status = AE_OK;
599 BOOLEAN LocalResult = FALSE;
600
601
581 return (Integer0 >> Integer1);
582
583
584 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
585
586 return (Integer0 - Integer1);
587
588 default:

--- 29 unchanged lines hidden (view full) ---

618 ACPI_INTEGER Integer0,
619 ACPI_INTEGER Integer1,
620 BOOLEAN *LogicalResult)
621{
622 ACPI_STATUS Status = AE_OK;
623 BOOLEAN LocalResult = FALSE;
624
625
602 ACPI_FUNCTION_TRACE ("ExDoLogicalNumericOp");
626 ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
603
604
605 switch (Opcode)
606 {
607 case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
608
609 if (Integer0 && Integer1)
610 {

--- 59 unchanged lines hidden (view full) ---

670 ACPI_INTEGER Integer1;
671 UINT32 Length0;
672 UINT32 Length1;
673 ACPI_STATUS Status = AE_OK;
674 BOOLEAN LocalResult = FALSE;
675 int Compare;
676
677
627
628
629 switch (Opcode)
630 {
631 case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
632
633 if (Integer0 && Integer1)
634 {

--- 59 unchanged lines hidden (view full) ---

694 ACPI_INTEGER Integer1;
695 UINT32 Length0;
696 UINT32 Length1;
697 ACPI_STATUS Status = AE_OK;
698 BOOLEAN LocalResult = FALSE;
699 int Compare;
700
701
678 ACPI_FUNCTION_TRACE ("ExDoLogicalOp");
702 ACPI_FUNCTION_TRACE (ExDoLogicalOp);
679
680
681 /*
682 * Convert the second operand if necessary. The first operand
683 * determines the type of the second operand, (See the Data Types
684 * section of the ACPI 3.0+ specification.) Both object types are
685 * guaranteed to be either Integer/String/Buffer by the operand
686 * resolution mechanism.

--- 163 unchanged lines hidden ---
703
704
705 /*
706 * Convert the second operand if necessary. The first operand
707 * determines the type of the second operand, (See the Data Types
708 * section of the ACPI 3.0+ specification.) Both object types are
709 * guaranteed to be either Integer/String/Buffer by the operand
710 * resolution mechanism.

--- 163 unchanged lines hidden ---