Deleted Added
full compact
dsopcode.c (99146) dsopcode.c (99679)
1/******************************************************************************
2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
4 * "control" opcodes
1/******************************************************************************
2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
4 * "control" opcodes
5 * $Revision: 74 $
5 * $Revision: 80 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

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

119
120#include "acpi.h"
121#include "acparser.h"
122#include "amlcode.h"
123#include "acdispat.h"
124#include "acinterp.h"
125#include "acnamesp.h"
126#include "acevents.h"
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

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

119
120#include "acpi.h"
121#include "acparser.h"
122#include "amlcode.h"
123#include "acdispat.h"
124#include "acinterp.h"
125#include "acnamesp.h"
126#include "acevents.h"
127#include "actables.h"
128
129#define _COMPONENT ACPI_DISPATCHER
130 ACPI_MODULE_NAME ("dsopcode")
131
132
133/*****************************************************************************
134 *
135 * FUNCTION: AcpiDsExecuteArguments
136 *
137 * PARAMETERS: Node - Parent NS node
127
128#define _COMPONENT ACPI_DISPATCHER
129 ACPI_MODULE_NAME ("dsopcode")
130
131
132/*****************************************************************************
133 *
134 * FUNCTION: AcpiDsExecuteArguments
135 *
136 * PARAMETERS: Node - Parent NS node
138 * ExtraDesc - Has AML pointer and length
137 * AmlLength - Length of executable AML
138 * AmlStart - Pointer to the AML
139 *
140 * RETURN: Status.
141 *
142 * DESCRIPTION: Late execution of region or field arguments
143 *
144 ****************************************************************************/
145
146ACPI_STATUS

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

165 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
166 if (!Op)
167 {
168 return_ACPI_STATUS (AE_NO_MEMORY);
169 }
170
171 /* Save the Node for use in AcpiPsParseAml */
172
139 *
140 * RETURN: Status.
141 *
142 * DESCRIPTION: Late execution of region or field arguments
143 *
144 ****************************************************************************/
145
146ACPI_STATUS

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

165 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
166 if (!Op)
167 {
168 return_ACPI_STATUS (AE_NO_MEMORY);
169 }
170
171 /* Save the Node for use in AcpiPsParseAml */
172
173 Op->Node = ScopeNode;
173 Op->Common.Node = ScopeNode;
174
175 /* Create and initialize a new parser state */
176
177 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
178 if (!WalkState)
179 {
180 return_ACPI_STATUS (AE_NO_MEMORY);
181 }

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

196 if (ACPI_FAILURE (Status))
197 {
198 AcpiPsDeleteParseTree (Op);
199 return_ACPI_STATUS (Status);
200 }
201
202 /* Get and init the Op created above */
203
174
175 /* Create and initialize a new parser state */
176
177 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
178 if (!WalkState)
179 {
180 return_ACPI_STATUS (AE_NO_MEMORY);
181 }

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

196 if (ACPI_FAILURE (Status))
197 {
198 AcpiPsDeleteParseTree (Op);
199 return_ACPI_STATUS (Status);
200 }
201
202 /* Get and init the Op created above */
203
204 Arg = Op->Value.Arg;
205 Op->Node = Node;
206 Arg->Node = Node;
204 Arg = Op->Common.Value.Arg;
205 Op->Common.Node = Node;
206 Arg->Common.Node = Node;
207 AcpiPsDeleteParseTree (Op);
208
209 /* Evaluate the address and length arguments for the Buffer Field */
210
211 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
212 if (!Op)
213 {
214 return_ACPI_STATUS (AE_NO_MEMORY);
215 }
216
207 AcpiPsDeleteParseTree (Op);
208
209 /* Evaluate the address and length arguments for the Buffer Field */
210
211 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
212 if (!Op)
213 {
214 return_ACPI_STATUS (AE_NO_MEMORY);
215 }
216
217 Op->Node = ScopeNode;
217 Op->Common.Node = ScopeNode;
218
219 /* Create and initialize a new parser state */
220
221 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
222 if (!WalkState)
223 {
224 return_ACPI_STATUS (AE_NO_MEMORY);
225 }

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

270
271 /* Get the AML pointer (method object) and BufferField node */
272
273 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
274 Node = ObjDesc->BufferField.Node;
275
276 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Field]"));
277 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n",
218
219 /* Create and initialize a new parser state */
220
221 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
222 if (!WalkState)
223 {
224 return_ACPI_STATUS (AE_NO_MEMORY);
225 }

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

270
271 /* Get the AML pointer (method object) and BufferField node */
272
273 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
274 Node = ObjDesc->BufferField.Node;
275
276 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Field]"));
277 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n",
278 (char *) &Node->Name));
278 Node->Name.Ascii));
279
280 /* Execute the AML code for the TermArg arguments */
281
282 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
283 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
284 return_ACPI_STATUS (Status);
285}
286

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

421
422 /* Get the Region node */
423
424 Node = ObjDesc->Region.Node;
425
426 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Operation Region]"));
427
428 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n",
279
280 /* Execute the AML code for the TermArg arguments */
281
282 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
283 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
284 return_ACPI_STATUS (Status);
285}
286

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

421
422 /* Get the Region node */
423
424 Node = ObjDesc->Region.Node;
425
426 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Operation Region]"));
427
428 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n",
429 (char *) &Node->Name, ExtraDesc->Extra.AmlStart));
429 Node->Name.Ascii, ExtraDesc->Extra.AmlStart));
430
431
432 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
433 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
434 return_ACPI_STATUS (Status);
435}
436
437
438/*****************************************************************************
439 *
440 * FUNCTION: AcpiDsInitializeRegion
441 *
442 * PARAMETERS: Op - A valid region Op object
443 *
444 * RETURN: Status
445 *
430
431
432 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
433 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
434 return_ACPI_STATUS (Status);
435}
436
437
438/*****************************************************************************
439 *
440 * FUNCTION: AcpiDsInitializeRegion
441 *
442 * PARAMETERS: Op - A valid region Op object
443 *
444 * RETURN: Status
445 *
446 * DESCRIPTION:
446 * DESCRIPTION: Front end to EvInitializeRegion
447 *
448 ****************************************************************************/
449
450ACPI_STATUS
451AcpiDsInitializeRegion (
452 ACPI_HANDLE ObjHandle)
453{
454 ACPI_OPERAND_OBJECT *ObjDesc;

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

461
462 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
463 return (Status);
464}
465
466
467/*****************************************************************************
468 *
447 *
448 ****************************************************************************/
449
450ACPI_STATUS
451AcpiDsInitializeRegion (
452 ACPI_HANDLE ObjHandle)
453{
454 ACPI_OPERAND_OBJECT *ObjDesc;

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

461
462 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
463 return (Status);
464}
465
466
467/*****************************************************************************
468 *
469 * FUNCTION: AcpiDsEvalBufferFieldOperands
469 * FUNCTION: AcpiDsInitBufferField
470 *
470 *
471 * PARAMETERS: Op - A valid BufferField Op object
471 * PARAMETERS: AmlOpcode - CreateXxxField
472 * ObjDesc - BufferField object
473 * BufferDesc - Host Buffer
474 * OffsetDesc - Offset into buffer
475 * Length - Length of field (CREATE_FIELD_OP only)
476 * Result - Where to store the result
472 *
473 * RETURN: Status
474 *
477 *
478 * RETURN: Status
479 *
475 * DESCRIPTION: Get BufferField Buffer and Index
476 * Called from AcpiDsExecEndOp during BufferField parse tree walk
480 * DESCRIPTION: Perform actual initialization of a buffer field
477 *
478 ****************************************************************************/
479
480ACPI_STATUS
481 *
482 ****************************************************************************/
483
484ACPI_STATUS
481AcpiDsEvalBufferFieldOperands (
482 ACPI_WALK_STATE *WalkState,
483 ACPI_PARSE_OBJECT *Op)
485AcpiDsInitBufferField (
486 UINT16 AmlOpcode,
487 ACPI_OPERAND_OBJECT *ObjDesc,
488 ACPI_OPERAND_OBJECT *BufferDesc,
489 ACPI_OPERAND_OBJECT *OffsetDesc,
490 ACPI_OPERAND_OBJECT *LengthDesc,
491 ACPI_OPERAND_OBJECT *ResultDesc)
484{
492{
485 ACPI_STATUS Status;
486 ACPI_OPERAND_OBJECT *ObjDesc;
487 ACPI_NAMESPACE_NODE *Node;
488 ACPI_PARSE_OBJECT *NextOp;
489 UINT32 Offset;
490 UINT32 BitOffset;
491 UINT32 BitCount;
492 UINT8 FieldFlags;
493 UINT32 Offset;
494 UINT32 BitOffset;
495 UINT32 BitCount;
496 UINT8 FieldFlags;
493 ACPI_OPERAND_OBJECT *ResDesc = NULL;
494 ACPI_OPERAND_OBJECT *CntDesc = NULL;
495 ACPI_OPERAND_OBJECT *OffDesc = NULL;
496 ACPI_OPERAND_OBJECT *SrcDesc = NULL;
497 ACPI_STATUS Status;
497
498
498
499
499 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op);
500 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc);
500
501
501
502
502 /*
503 * This is where we evaluate the address and length fields of the
504 * CreateXxxField declaration
505 */
506 Node = Op->Node;
503 /* Host object must be a Buffer */
507
504
508 /* NextOp points to the op that holds the Buffer */
509
510 NextOp = Op->Value.Arg;
511
512 /* Evaluate/create the address and length operands */
513
514 Status = AcpiDsCreateOperands (WalkState, NextOp);
515 if (ACPI_FAILURE (Status))
505 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER)
516 {
506 {
517 return_ACPI_STATUS (Status);
518 }
507 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
508 "Target of Create Field is not a Buffer object - %s\n",
509 AcpiUtGetObjectTypeName (BufferDesc)));
519
510
520 ObjDesc = AcpiNsGetAttachedObject (Node);
521 if (!ObjDesc)
522 {
523 return_ACPI_STATUS (AE_NOT_EXIST);
524 }
525
526 /* Resolve the operands */
527
528 Status = AcpiExResolveOperands (Op->Opcode, ACPI_WALK_OPERANDS, WalkState);
529 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Opcode),
530 WalkState->NumOperands, "after AcpiExResolveOperands");
531
532 if (ACPI_FAILURE (Status))
533 {
534 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
535 AcpiPsGetOpcodeName (Op->Opcode), Status));
536
511 Status = AE_AML_OPERAND_TYPE;
537 goto Cleanup;
538 }
539
512 goto Cleanup;
513 }
514
540 /* Get the operands */
541
542 if (AML_CREATE_FIELD_OP == Op->Opcode)
543 {
544 ResDesc = WalkState->Operands[3];
545 CntDesc = WalkState->Operands[2];
546 }
547 else
548 {
549 ResDesc = WalkState->Operands[2];
550 }
551
552 OffDesc = WalkState->Operands[1];
553 SrcDesc = WalkState->Operands[0];
554 Offset = (UINT32) OffDesc->Integer.Value;
555
556 /*
515 /*
557 * If ResDesc is a Name, it will be a direct name pointer after
558 * AcpiExResolveOperands()
516 * The last parameter to all of these opcodes (ResultDesc) started
517 * out as a NameString, and should therefore now be a NS node
518 * after resolution in AcpiExResolveOperands().
559 */
519 */
560 if (ACPI_GET_DESCRIPTOR_TYPE (ResDesc) != ACPI_DESC_TYPE_NAMED)
520 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
561 {
562 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
521 {
522 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
563 AcpiPsGetOpcodeName (Op->Opcode)));
523 AcpiPsGetOpcodeName (AmlOpcode)));
564
565 Status = AE_AML_OPERAND_TYPE;
566 goto Cleanup;
567 }
568
524
525 Status = AE_AML_OPERAND_TYPE;
526 goto Cleanup;
527 }
528
529 Offset = (UINT32) OffsetDesc->Integer.Value;
530
569 /*
570 * Setup the Bit offsets and counts, according to the opcode
571 */
531 /*
532 * Setup the Bit offsets and counts, according to the opcode
533 */
572 switch (Op->Opcode)
534 switch (AmlOpcode)
573 {
574 case AML_CREATE_FIELD_OP:
575
576 /* Offset is in bits, count is in bits */
577
535 {
536 case AML_CREATE_FIELD_OP:
537
538 /* Offset is in bits, count is in bits */
539
578 BitOffset = Offset;
579 BitCount = (UINT32) CntDesc->Integer.Value;
580 FieldFlags = AML_FIELD_ACCESS_BYTE;
540 BitOffset = Offset;
541 BitCount = (UINT32) LengthDesc->Integer.Value;
542 FieldFlags = AML_FIELD_ACCESS_BYTE;
581 break;
582
583 case AML_CREATE_BIT_FIELD_OP:
584
585 /* Offset is in bits, Field is one bit */
586
543 break;
544
545 case AML_CREATE_BIT_FIELD_OP:
546
547 /* Offset is in bits, Field is one bit */
548
587 BitOffset = Offset;
588 BitCount = 1;
589 FieldFlags = AML_FIELD_ACCESS_BYTE;
549 BitOffset = Offset;
550 BitCount = 1;
551 FieldFlags = AML_FIELD_ACCESS_BYTE;
590 break;
591
592 case AML_CREATE_BYTE_FIELD_OP:
593
594 /* Offset is in bytes, field is one byte */
595
552 break;
553
554 case AML_CREATE_BYTE_FIELD_OP:
555
556 /* Offset is in bytes, field is one byte */
557
596 BitOffset = 8 * Offset;
597 BitCount = 8;
598 FieldFlags = AML_FIELD_ACCESS_BYTE;
558 BitOffset = 8 * Offset;
559 BitCount = 8;
560 FieldFlags = AML_FIELD_ACCESS_BYTE;
599 break;
600
601 case AML_CREATE_WORD_FIELD_OP:
602
603 /* Offset is in bytes, field is one word */
604
561 break;
562
563 case AML_CREATE_WORD_FIELD_OP:
564
565 /* Offset is in bytes, field is one word */
566
605 BitOffset = 8 * Offset;
606 BitCount = 16;
607 FieldFlags = AML_FIELD_ACCESS_WORD;
567 BitOffset = 8 * Offset;
568 BitCount = 16;
569 FieldFlags = AML_FIELD_ACCESS_WORD;
608 break;
609
610 case AML_CREATE_DWORD_FIELD_OP:
611
612 /* Offset is in bytes, field is one dword */
613
570 break;
571
572 case AML_CREATE_DWORD_FIELD_OP:
573
574 /* Offset is in bytes, field is one dword */
575
614 BitOffset = 8 * Offset;
615 BitCount = 32;
616 FieldFlags = AML_FIELD_ACCESS_DWORD;
576 BitOffset = 8 * Offset;
577 BitCount = 32;
578 FieldFlags = AML_FIELD_ACCESS_DWORD;
617 break;
618
619 case AML_CREATE_QWORD_FIELD_OP:
620
621 /* Offset is in bytes, field is one qword */
622
579 break;
580
581 case AML_CREATE_QWORD_FIELD_OP:
582
583 /* Offset is in bytes, field is one qword */
584
623 BitOffset = 8 * Offset;
624 BitCount = 64;
625 FieldFlags = AML_FIELD_ACCESS_QWORD;
585 BitOffset = 8 * Offset;
586 BitCount = 64;
587 FieldFlags = AML_FIELD_ACCESS_QWORD;
626 break;
627
628 default:
629
630 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
588 break;
589
590 default:
591
592 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
631 "Internal error - unknown field creation opcode %02x\n",
632 Op->Opcode));
593 "Unknown field creation opcode %02x\n",
594 AmlOpcode));
633 Status = AE_AML_BAD_OPCODE;
634 goto Cleanup;
635 }
636
595 Status = AE_AML_BAD_OPCODE;
596 goto Cleanup;
597 }
598
599
600 /* Entire field must fit within the current length of the buffer */
601
602 if ((BitOffset + BitCount) >
603 (8 * (UINT32) BufferDesc->Buffer.Length))
604 {
605 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
606 "Field size %d exceeds Buffer size %d (bits)\n",
607 BitOffset + BitCount, 8 * (UINT32) BufferDesc->Buffer.Length));
608 Status = AE_AML_BUFFER_LIMIT;
609 goto Cleanup;
610 }
611
637 /*
612 /*
638 * Setup field according to the object type
613 * Initialize areas of the field object that are common to all fields
614 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
639 */
615 */
640 switch (SrcDesc->Common.Type)
616 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
617 BitOffset, BitCount);
618 if (ACPI_FAILURE (Status))
641 {
619 {
620 goto Cleanup;
621 }
642
622
643 /* SourceBuff := TermArg=>Buffer */
623 ObjDesc->BufferField.BufferObj = BufferDesc;
644
624
645 case ACPI_TYPE_BUFFER:
625 /* Reference count for BufferDesc inherits ObjDesc count */
646
626
647 if ((BitOffset + BitCount) >
648 (8 * (UINT32) SrcDesc->Buffer.Length))
649 {
650 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
651 "Field size %d exceeds Buffer size %d (bits)\n",
652 BitOffset + BitCount, 8 * (UINT32) SrcDesc->Buffer.Length));
653 Status = AE_AML_BUFFER_LIMIT;
654 goto Cleanup;
655 }
627 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount +
628 ObjDesc->Common.ReferenceCount);
656
629
657 /*
658 * Initialize areas of the field object that are common to all fields
659 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
660 */
661 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
662 BitOffset, BitCount);
663 if (ACPI_FAILURE (Status))
664 {
665 return_ACPI_STATUS (Status);
666 }
667
630
668 ObjDesc->BufferField.BufferObj = SrcDesc;
631Cleanup:
669
632
670 /* Reference count for SrcDesc inherits ObjDesc count */
633 /* Always delete the operands */
671
634
672 SrcDesc->Common.ReferenceCount = (UINT16) (SrcDesc->Common.ReferenceCount +
673 ObjDesc->Common.ReferenceCount);
674 break;
635 AcpiUtRemoveReference (OffsetDesc);
636 AcpiUtRemoveReference (BufferDesc);
675
637
638 if (AmlOpcode == AML_CREATE_FIELD_OP)
639 {
640 AcpiUtRemoveReference (LengthDesc);
641 }
676
642
677 /* Improper object type */
643 /* On failure, delete the result descriptor */
678
644
679 default:
645 if (ACPI_FAILURE (Status))
646 {
647 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */
648 }
649 else
650 {
651 /* Now the address and length are valid for this BufferField */
680
652
681 if ((SrcDesc->Common.Type > (UINT8) INTERNAL_TYPE_REFERENCE) || !AcpiUtValidObjectType (SrcDesc->Common.Type)) /* This line MUST be a single line until AcpiSrc can handle it (block deletion) */
682 {
683 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
684 "Tried to create field in invalid object type %X\n",
685 SrcDesc->Common.Type));
686 }
687 else
688 {
689 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
690 "Tried to create field in improper object type - %s\n",
691 AcpiUtGetTypeName (SrcDesc->Common.Type)));
692 }
693
694 Status = AE_AML_OPERAND_TYPE;
695 goto Cleanup;
653 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
696 }
697
654 }
655
656 return_ACPI_STATUS (Status);
657}
698
658
699 if (AML_CREATE_FIELD_OP == Op->Opcode)
700 {
701 /* Delete object descriptor unique to CreateField */
702
659
703 AcpiUtRemoveReference (CntDesc);
704 CntDesc = NULL;
705 }
660/*****************************************************************************
661 *
662 * FUNCTION: AcpiDsEvalBufferFieldOperands
663 *
664 * PARAMETERS: WalkState - Current walk
665 * Op - A valid BufferField Op object
666 *
667 * RETURN: Status
668 *
669 * DESCRIPTION: Get BufferField Buffer and Index
670 * Called from AcpiDsExecEndOp during BufferField parse tree walk
671 *
672 ****************************************************************************/
706
673
674ACPI_STATUS
675AcpiDsEvalBufferFieldOperands (
676 ACPI_WALK_STATE *WalkState,
677 ACPI_PARSE_OBJECT *Op)
678{
679 ACPI_STATUS Status;
680 ACPI_OPERAND_OBJECT *ObjDesc;
681 ACPI_NAMESPACE_NODE *Node;
682 ACPI_PARSE_OBJECT *NextOp;
707
683
708Cleanup:
709
684
710 /* Always delete the operands */
685 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op);
711
686
712 AcpiUtRemoveReference (OffDesc);
713 AcpiUtRemoveReference (SrcDesc);
714
687
715 if (AML_CREATE_FIELD_OP == Op->Opcode)
688 /*
689 * This is where we evaluate the address and length fields of the
690 * CreateXxxField declaration
691 */
692 Node = Op->Common.Node;
693
694 /* NextOp points to the op that holds the Buffer */
695
696 NextOp = Op->Common.Value.Arg;
697
698 /* Evaluate/create the address and length operands */
699
700 Status = AcpiDsCreateOperands (WalkState, NextOp);
701 if (ACPI_FAILURE (Status))
716 {
702 {
717 AcpiUtRemoveReference (CntDesc);
703 return_ACPI_STATUS (Status);
718 }
719
704 }
705
720 /* On failure, delete the result descriptor */
706 ObjDesc = AcpiNsGetAttachedObject (Node);
707 if (!ObjDesc)
708 {
709 return_ACPI_STATUS (AE_NOT_EXIST);
710 }
721
711
712 /* Resolve the operands */
713
714 Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
715 ACPI_WALK_OPERANDS, WalkState);
716
717 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
718 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
719 WalkState->NumOperands, "after AcpiExResolveOperands");
720
722 if (ACPI_FAILURE (Status))
723 {
721 if (ACPI_FAILURE (Status))
722 {
724 AcpiUtRemoveReference (ResDesc); /* Result descriptor */
723 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
724 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
725
726 return_ACPI_STATUS (Status);
725 }
727 }
728
729 /* Initialize the Buffer Field */
730
731 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
732 {
733 /* NOTE: Slightly different operands for this opcode */
734
735 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
736 WalkState->Operands[0], WalkState->Operands[1],
737 WalkState->Operands[2], WalkState->Operands[3]);
738 }
726 else
727 {
739 else
740 {
728 /* Now the address and length are valid for this BufferField */
741 /* All other, CreateXxxField opcodes */
729
742
730 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
743 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
744 WalkState->Operands[0], WalkState->Operands[1],
745 NULL, WalkState->Operands[2]);
731 }
732
733 return_ACPI_STATUS (Status);
734}
735
736
737/*****************************************************************************
738 *
739 * FUNCTION: AcpiDsEvalRegionOperands
740 *
746 }
747
748 return_ACPI_STATUS (Status);
749}
750
751
752/*****************************************************************************
753 *
754 * FUNCTION: AcpiDsEvalRegionOperands
755 *
741 * PARAMETERS: Op - A valid region Op object
756 * PARAMETERS: WalkState - Current walk
757 * Op - A valid region Op object
742 *
743 * RETURN: Status
744 *
745 * DESCRIPTION: Get region address and length
746 * Called from AcpiDsExecEndOp during OpRegion parse tree walk
747 *
748 ****************************************************************************/
749

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

760
761
762 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op);
763
764
765 /*
766 * This is where we evaluate the address and length fields of the OpRegion declaration
767 */
758 *
759 * RETURN: Status
760 *
761 * DESCRIPTION: Get region address and length
762 * Called from AcpiDsExecEndOp during OpRegion parse tree walk
763 *
764 ****************************************************************************/
765

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

776
777
778 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op);
779
780
781 /*
782 * This is where we evaluate the address and length fields of the OpRegion declaration
783 */
768 Node = Op->Node;
784 Node = Op->Common.Node;
769
770 /* NextOp points to the op that holds the SpaceID */
771
785
786 /* NextOp points to the op that holds the SpaceID */
787
772 NextOp = Op->Value.Arg;
788 NextOp = Op->Common.Value.Arg;
773
774 /* NextOp points to address op */
775
789
790 /* NextOp points to address op */
791
776 NextOp = NextOp->Next;
792 NextOp = NextOp->Common.Next;
777
778 /* Evaluate/create the address and length operands */
779
780 Status = AcpiDsCreateOperands (WalkState, NextOp);
781 if (ACPI_FAILURE (Status))
782 {
783 return_ACPI_STATUS (Status);
784 }
785
786 /* Resolve the length and address operands to numbers */
787
793
794 /* Evaluate/create the address and length operands */
795
796 Status = AcpiDsCreateOperands (WalkState, NextOp);
797 if (ACPI_FAILURE (Status))
798 {
799 return_ACPI_STATUS (Status);
800 }
801
802 /* Resolve the length and address operands to numbers */
803
788 Status = AcpiExResolveOperands (Op->Opcode, ACPI_WALK_OPERANDS, WalkState);
804 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
789 if (ACPI_FAILURE (Status))
790 {
791 return_ACPI_STATUS (Status);
792 }
793
794 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
805 if (ACPI_FAILURE (Status))
806 {
807 return_ACPI_STATUS (Status);
808 }
809
810 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
795 AcpiPsGetOpcodeName (Op->Opcode),
811 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
796 1, "after AcpiExResolveOperands");
797
798 ObjDesc = AcpiNsGetAttachedObject (Node);
799 if (!ObjDesc)
800 {
801 return_ACPI_STATUS (AE_NOT_EXIST);
802 }
803

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

832}
833
834
835
836/*****************************************************************************
837 *
838 * FUNCTION: AcpiDsEvalDataObjectOperands
839 *
812 1, "after AcpiExResolveOperands");
813
814 ObjDesc = AcpiNsGetAttachedObject (Node);
815 if (!ObjDesc)
816 {
817 return_ACPI_STATUS (AE_NOT_EXIST);
818 }
819

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

848}
849
850
851
852/*****************************************************************************
853 *
854 * FUNCTION: AcpiDsEvalDataObjectOperands
855 *
840 * PARAMETERS: Op - A valid DataObject Op object
856 * PARAMETERS: WalkState - Current walk
857 * Op - A valid DataObject Op object
858 * ObjDesc - DataObject
841 *
842 * RETURN: Status
843 *
844 * DESCRIPTION: Get the operands and complete the following data objec types:
845 * Buffer
846 * Package
847 *
848 ****************************************************************************/

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

858 UINT32 Length;
859
860
861 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands");
862
863
864 /* The first operand (for all of these data objects) is the length */
865
859 *
860 * RETURN: Status
861 *
862 * DESCRIPTION: Get the operands and complete the following data objec types:
863 * Buffer
864 * Package
865 *
866 ****************************************************************************/

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

876 UINT32 Length;
877
878
879 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands");
880
881
882 /* The first operand (for all of these data objects) is the length */
883
866 Status = AcpiDsCreateOperand (WalkState, Op->Value.Arg, 1);
884 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
867 if (ACPI_FAILURE (Status))
868 {
869 return_ACPI_STATUS (Status);
870 }
871
872 Status = AcpiExResolveOperands (WalkState->Opcode,
873 &(WalkState->Operands [WalkState->NumOperands -1]),
874 WalkState);

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

879
880 /* Extract length operand */
881
882 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
883 Length = (UINT32) ArgDesc->Integer.Value;
884
885 /* Cleanup for length operand */
886
885 if (ACPI_FAILURE (Status))
886 {
887 return_ACPI_STATUS (Status);
888 }
889
890 Status = AcpiExResolveOperands (WalkState->Opcode,
891 &(WalkState->Operands [WalkState->NumOperands -1]),
892 WalkState);

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

897
898 /* Extract length operand */
899
900 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
901 Length = (UINT32) ArgDesc->Integer.Value;
902
903 /* Cleanup for length operand */
904
887 AcpiDsObjStackPop (1, WalkState);
905 Status = AcpiDsObjStackPop (1, WalkState);
906 if (ACPI_FAILURE (Status))
907 {
908 return_ACPI_STATUS (Status);
909 }
910
888 AcpiUtRemoveReference (ArgDesc);
889
890 /*
891 * Create the actual data object
892 */
911 AcpiUtRemoveReference (ArgDesc);
912
913 /*
914 * Create the actual data object
915 */
893 switch (Op->Opcode)
916 switch (Op->Common.AmlOpcode)
894 {
895 case AML_BUFFER_OP:
896
897 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc);
898 break;
899
900 case AML_PACKAGE_OP:
901 case AML_VAR_PACKAGE_OP:

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

909
910 if (ACPI_SUCCESS (Status))
911 {
912 /*
913 * Return the object in the WalkState, unless the parent is a package --
914 * in this case, the return object will be stored in the parse tree
915 * for the package.
916 */
917 {
918 case AML_BUFFER_OP:
919
920 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc);
921 break;
922
923 case AML_PACKAGE_OP:
924 case AML_VAR_PACKAGE_OP:

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

932
933 if (ACPI_SUCCESS (Status))
934 {
935 /*
936 * Return the object in the WalkState, unless the parent is a package --
937 * in this case, the return object will be stored in the parse tree
938 * for the package.
939 */
917 if ((!Op->Parent) ||
918 ((Op->Parent->Opcode != AML_PACKAGE_OP) &&
919 (Op->Parent->Opcode != AML_VAR_PACKAGE_OP) &&
920 (Op->Parent->Opcode != AML_NAME_OP)))
940 if ((!Op->Common.Parent) ||
941 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
942 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
943 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
921 {
922 WalkState->ResultObj = ObjDesc;
923 }
924 }
925
926 return_ACPI_STATUS (Status);
927}
928

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

950 ACPI_STATUS Status = AE_OK;
951 ACPI_GENERIC_STATE *ControlState;
952
953
954 ACPI_FUNCTION_NAME ("DsExecBeginControlOp");
955
956
957 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op,
944 {
945 WalkState->ResultObj = ObjDesc;
946 }
947 }
948
949 return_ACPI_STATUS (Status);
950}
951

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

973 ACPI_STATUS Status = AE_OK;
974 ACPI_GENERIC_STATE *ControlState;
975
976
977 ACPI_FUNCTION_NAME ("DsExecBeginControlOp");
978
979
980 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op,
958 Op->Opcode, WalkState));
981 Op->Common.AmlOpcode, WalkState));
959
982
960 switch (Op->Opcode)
983 switch (Op->Common.AmlOpcode)
961 {
962 case AML_IF_OP:
963 case AML_WHILE_OP:
964
965 /*
966 * IF/WHILE: Create a new control state to manage these
967 * constructs. We need to manage these as a stack, in order
968 * to handle nesting.

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

974 break;
975 }
976 /*
977 * Save a pointer to the predicate for multiple executions
978 * of a loop
979 */
980 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
981 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
984 {
985 case AML_IF_OP:
986 case AML_WHILE_OP:
987
988 /*
989 * IF/WHILE: Create a new control state to manage these
990 * constructs. We need to manage these as a stack, in order
991 * to handle nesting.

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

997 break;
998 }
999 /*
1000 * Save a pointer to the predicate for multiple executions
1001 * of a loop
1002 */
1003 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
1004 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
982 ControlState->Control.Opcode = Op->Opcode;
1005 ControlState->Control.Opcode = Op->Common.AmlOpcode;
983
984
985 /* Push the control state on this walk's control stack */
986
987 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
988 break;
989
990 case AML_ELSE_OP:

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

1032{
1033 ACPI_STATUS Status = AE_OK;
1034 ACPI_GENERIC_STATE *ControlState;
1035
1036
1037 ACPI_FUNCTION_NAME ("DsExecEndControlOp");
1038
1039
1006
1007
1008 /* Push the control state on this walk's control stack */
1009
1010 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
1011 break;
1012
1013 case AML_ELSE_OP:

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

1055{
1056 ACPI_STATUS Status = AE_OK;
1057 ACPI_GENERIC_STATE *ControlState;
1058
1059
1060 ACPI_FUNCTION_NAME ("DsExecEndControlOp");
1061
1062
1040 switch (Op->Opcode)
1063 switch (Op->Common.AmlOpcode)
1041 {
1042 case AML_IF_OP:
1043
1044 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
1045
1046 /*
1047 * Save the result of the predicate in case there is an
1048 * ELSE to come

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

1084 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
1085 AcpiUtDeleteGenericState (ControlState);
1086 break;
1087
1088
1089 case AML_RETURN_OP:
1090
1091 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1064 {
1065 case AML_IF_OP:
1066
1067 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
1068
1069 /*
1070 * Save the result of the predicate in case there is an
1071 * ELSE to come

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

1107 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
1108 AcpiUtDeleteGenericState (ControlState);
1109 break;
1110
1111
1112 case AML_RETURN_OP:
1113
1114 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1092 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Value.Arg));
1115 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
1093
1094 /*
1095 * One optional operand -- the return value
1096 * It can be either an immediate operand or a result that
1097 * has been bubbled up the tree
1098 */
1116
1117 /*
1118 * One optional operand -- the return value
1119 * It can be either an immediate operand or a result that
1120 * has been bubbled up the tree
1121 */
1099 if (Op->Value.Arg)
1122 if (Op->Common.Value.Arg)
1100 {
1101 /* Return statement has an immediate operand */
1102
1123 {
1124 /* Return statement has an immediate operand */
1125
1103 Status = AcpiDsCreateOperands (WalkState, Op->Value.Arg);
1126 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
1104 if (ACPI_FAILURE (Status))
1105 {
1106 return (Status);
1107 }
1108
1109 /*
1110 * If value being returned is a Reference (such as
1111 * an arg or local), resolve it now because it may

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

1131 * The return value has come from a previous calculation.
1132 *
1133 * If value being returned is a Reference (such as
1134 * an arg or local), resolve it now because it may
1135 * cease to exist at the end of the method.
1136 *
1137 * Allow references created by the Index operator to return unchanged.
1138 */
1127 if (ACPI_FAILURE (Status))
1128 {
1129 return (Status);
1130 }
1131
1132 /*
1133 * If value being returned is a Reference (such as
1134 * an arg or local), resolve it now because it may

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

1154 * The return value has come from a previous calculation.
1155 *
1156 * If value being returned is a Reference (such as
1157 * an arg or local), resolve it now because it may
1158 * cease to exist at the end of the method.
1159 *
1160 * Allow references created by the Index operator to return unchanged.
1161 */
1139 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_INTERNAL) &&
1140 ((WalkState->Results->Results.ObjDesc [0])->Common.Type == INTERNAL_TYPE_REFERENCE) &&
1162 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
1163 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == INTERNAL_TYPE_REFERENCE) &&
1141 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP))
1142 {
1143 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
1144 if (ACPI_FAILURE (Status))
1145 {
1146 return (Status);
1147 }
1148 }

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

1179 /* Just do nothing! */
1180 break;
1181
1182
1183 case AML_BREAK_POINT_OP:
1184
1185 /* Call up to the OS service layer to handle this */
1186
1164 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP))
1165 {
1166 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
1167 if (ACPI_FAILURE (Status))
1168 {
1169 return (Status);
1170 }
1171 }

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

1202 /* Just do nothing! */
1203 break;
1204
1205
1206 case AML_BREAK_POINT_OP:
1207
1208 /* Call up to the OS service layer to handle this */
1209
1187 AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
1210 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
1188
1189 /* If and when it returns, all done. */
1190
1191 break;
1192
1193
1194 case AML_BREAK_OP:
1195 case AML_CONTINUE_OP: /* ACPI 2.0 */

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

1212 }
1213
1214 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
1215
1216 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
1217
1218 /* Return status depending on opcode */
1219
1211
1212 /* If and when it returns, all done. */
1213
1214 break;
1215
1216
1217 case AML_BREAK_OP:
1218 case AML_CONTINUE_OP: /* ACPI 2.0 */

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

1235 }
1236
1237 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
1238
1239 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
1240
1241 /* Return status depending on opcode */
1242
1220 if (Op->Opcode == AML_BREAK_OP)
1243 if (Op->Common.AmlOpcode == AML_BREAK_OP)
1221 {
1222 Status = AE_CTRL_BREAK;
1223 }
1224 else
1225 {
1226 Status = AE_CTRL_CONTINUE;
1227 }
1228 break;
1229
1230
1231 default:
1232
1233 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
1244 {
1245 Status = AE_CTRL_BREAK;
1246 }
1247 else
1248 {
1249 Status = AE_CTRL_CONTINUE;
1250 }
1251 break;
1252
1253
1254 default:
1255
1256 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
1234 Op->Opcode, Op));
1257 Op->Common.AmlOpcode, Op));
1235
1236 Status = AE_AML_BAD_OPCODE;
1237 break;
1238 }
1239
1240 return (Status);
1241}
1242
1258
1259 Status = AE_AML_BAD_OPCODE;
1260 break;
1261 }
1262
1263 return (Status);
1264}
1265