1 /******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
524 while (Arg)
525 {
526 /*
527 * We must delete any package elements that were created earlier
528 * and are not going to be used because of the package truncation.
529 */
530 if (Arg->Common.Node)
531 {
532 AcpiUtRemoveReference (
533 ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node));
534 Arg->Common.Node = NULL;
535 }
536
537 /* Find out how many elements there really are */
538
539 i++;
540 Arg = Arg->Common.Next;
541 }
542
543 ACPI_INFO ((AE_INFO,
544 "Actual Package length (%u) is larger than NumElements field (%u), truncated\n",
545 i, ElementCount));
546 }
547 else if (i < ElementCount)
548 {
549 /*
550 * Arg list (elements) was exhausted, but we did not reach NumElements count.
551 * Note: this is not an error, the package is padded out with NULLs.
552 */
553 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
554 "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n",
555 i, ElementCount));
556 }
557
558 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
559 Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
560 return_ACPI_STATUS (Status);
561 }
562
563
564 /*******************************************************************************
660 ACPI_STATUS Status = AE_OK;
661
662
663 ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
664
665
666 ObjDesc = *RetObjDesc;
667 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
668 if (OpInfo->Class == AML_CLASS_UNKNOWN)
669 {
670 /* Unknown opcode */
671
672 return_ACPI_STATUS (AE_TYPE);
673 }
674
675 /* Perform per-object initialization */
676
677 switch (ObjDesc->Common.Type)
678 {
679 case ACPI_TYPE_BUFFER:
680
681 /*
682 * Defer evaluation of Buffer TermArg operand
683 */
684 ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
685 WalkState->Operands[0]);
686 ObjDesc->Buffer.AmlStart = Op->Named.Data;
687 ObjDesc->Buffer.AmlLength = Op->Named.Length;
688 break;
689
690
691 case ACPI_TYPE_PACKAGE:
692
693 /*
694 * Defer evaluation of Package TermArg operand
695 */
696 ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
697 WalkState->Operands[0]);
698 ObjDesc->Package.AmlStart = Op->Named.Data;
699 ObjDesc->Package.AmlLength = Op->Named.Length;
700 break;
701
702
703 case ACPI_TYPE_INTEGER:
704
705 switch (OpInfo->Type)
706 {
707 case AML_TYPE_CONSTANT:
708 /*
709 * Resolve AML Constants here - AND ONLY HERE!
710 * All constants are integers.
711 * We mark the integer with a flag that indicates that it started
712 * life as a constant -- so that stores to constants will perform
713 * as expected (noop). ZeroOp is used as a placeholder for optional
714 * target operands.
715 */
716 ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
717
718 switch (Opcode)
719 {
720 case AML_ZERO_OP:
721
722 ObjDesc->Integer.Value = 0;
723 break;
724
725 case AML_ONE_OP:
726
727 ObjDesc->Integer.Value = 1;
728 break;
729
730 case AML_ONES_OP:
731
732 ObjDesc->Integer.Value = ACPI_UINT64_MAX;
733
734 /* Truncate value if we are executing from a 32-bit ACPI table */
735
736 #ifndef ACPI_NO_METHOD_EXECUTION
737 AcpiExTruncateFor32bitTable (ObjDesc);
738 #endif
739 break;
740
741 case AML_REVISION_OP:
742
743 ObjDesc->Integer.Value = ACPI_CA_VERSION;
744 break;
745
746 default:
747
748 ACPI_ERROR ((AE_INFO,
749 "Unknown constant opcode 0x%X", Opcode));
750 Status = AE_AML_OPERAND_TYPE;
751 break;
752 }
753 break;
754
755
756 case AML_TYPE_LITERAL:
757
758 ObjDesc->Integer.Value = Op->Common.Value.Integer;
759 #ifndef ACPI_NO_METHOD_EXECUTION
760 AcpiExTruncateFor32bitTable (ObjDesc);
761 #endif
762 break;
763
764
765 default:
766 ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
767 OpInfo->Type));
768 Status = AE_AML_OPERAND_TYPE;
769 break;
770 }
771 break;
772
773
774 case ACPI_TYPE_STRING:
775
776 ObjDesc->String.Pointer = Op->Common.Value.String;
777 ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String);
778
779 /*
780 * The string is contained in the ACPI table, don't ever try
781 * to delete it
782 */
783 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
784 break;
785
786
787 case ACPI_TYPE_METHOD:
788 break;
789
790
791 case ACPI_TYPE_LOCAL_REFERENCE:
792
793 switch (OpInfo->Type)
794 {
795 case AML_TYPE_LOCAL_VARIABLE:
796
797 /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
798
799 ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP;
800 ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
801
802 #ifndef ACPI_NO_METHOD_EXECUTION
803 Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
804 ObjDesc->Reference.Value, WalkState,
805 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
806 &ObjDesc->Reference.Object));
807 #endif
808 break;
809
810
811 case AML_TYPE_METHOD_ARGUMENT:
812
813 /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
814
815 ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP;
816 ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
817
818 #ifndef ACPI_NO_METHOD_EXECUTION
819 Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
820 ObjDesc->Reference.Value, WalkState,
821 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
822 &ObjDesc->Reference.Object));
823 #endif
824 break;
825
826 default: /* Object name or Debug object */
827
828 switch (Op->Common.AmlOpcode)
829 {
830 case AML_INT_NAMEPATH_OP:
834 ObjDesc->Reference.Node = Op->Common.Node;
835 ObjDesc->Reference.Object = Op->Common.Node->Object;
836 ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
837 break;
838
839 case AML_DEBUG_OP:
840
841 ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
842 break;
843
844 default:
845
846 ACPI_ERROR ((AE_INFO,
847 "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
848 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
849 }
850 break;
851 }
852 break;
853
854
855 default:
856
857 ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
858 ObjDesc->Common.Type));
859
860 Status = AE_AML_OPERAND_TYPE;
861 break;
862 }
863
864 return_ACPI_STATUS (Status);
865 }
866
867
|
1 /******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
524 while (Arg)
525 {
526 /*
527 * We must delete any package elements that were created earlier
528 * and are not going to be used because of the package truncation.
529 */
530 if (Arg->Common.Node)
531 {
532 AcpiUtRemoveReference (
533 ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node));
534 Arg->Common.Node = NULL;
535 }
536
537 /* Find out how many elements there really are */
538
539 i++;
540 Arg = Arg->Common.Next;
541 }
542
543 ACPI_INFO ((AE_INFO,
544 "Actual Package length (%u) is larger than NumElements field (%u), truncated",
545 i, ElementCount));
546 }
547 else if (i < ElementCount)
548 {
549 /*
550 * Arg list (elements) was exhausted, but we did not reach NumElements count.
551 * Note: this is not an error, the package is padded out with NULLs.
552 */
553 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
554 "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n",
555 i, ElementCount));
556 }
557
558 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
559 Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
560 return_ACPI_STATUS (Status);
561 }
562
563
564 /*******************************************************************************
660 ACPI_STATUS Status = AE_OK;
661
662
663 ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
664
665
666 ObjDesc = *RetObjDesc;
667 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
668 if (OpInfo->Class == AML_CLASS_UNKNOWN)
669 {
670 /* Unknown opcode */
671
672 return_ACPI_STATUS (AE_TYPE);
673 }
674
675 /* Perform per-object initialization */
676
677 switch (ObjDesc->Common.Type)
678 {
679 case ACPI_TYPE_BUFFER:
680 /*
681 * Defer evaluation of Buffer TermArg operand
682 */
683 ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
684 WalkState->Operands[0]);
685 ObjDesc->Buffer.AmlStart = Op->Named.Data;
686 ObjDesc->Buffer.AmlLength = Op->Named.Length;
687 break;
688
689 case ACPI_TYPE_PACKAGE:
690 /*
691 * Defer evaluation of Package TermArg operand
692 */
693 ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
694 WalkState->Operands[0]);
695 ObjDesc->Package.AmlStart = Op->Named.Data;
696 ObjDesc->Package.AmlLength = Op->Named.Length;
697 break;
698
699 case ACPI_TYPE_INTEGER:
700
701 switch (OpInfo->Type)
702 {
703 case AML_TYPE_CONSTANT:
704 /*
705 * Resolve AML Constants here - AND ONLY HERE!
706 * All constants are integers.
707 * We mark the integer with a flag that indicates that it started
708 * life as a constant -- so that stores to constants will perform
709 * as expected (noop). ZeroOp is used as a placeholder for optional
710 * target operands.
711 */
712 ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
713
714 switch (Opcode)
715 {
716 case AML_ZERO_OP:
717
718 ObjDesc->Integer.Value = 0;
719 break;
720
721 case AML_ONE_OP:
722
723 ObjDesc->Integer.Value = 1;
724 break;
725
726 case AML_ONES_OP:
727
728 ObjDesc->Integer.Value = ACPI_UINT64_MAX;
729
730 /* Truncate value if we are executing from a 32-bit ACPI table */
731
732 #ifndef ACPI_NO_METHOD_EXECUTION
733 (void) AcpiExTruncateFor32bitTable (ObjDesc);
734 #endif
735 break;
736
737 case AML_REVISION_OP:
738
739 ObjDesc->Integer.Value = ACPI_CA_VERSION;
740 break;
741
742 default:
743
744 ACPI_ERROR ((AE_INFO,
745 "Unknown constant opcode 0x%X", Opcode));
746 Status = AE_AML_OPERAND_TYPE;
747 break;
748 }
749 break;
750
751 case AML_TYPE_LITERAL:
752
753 ObjDesc->Integer.Value = Op->Common.Value.Integer;
754
755 #ifndef ACPI_NO_METHOD_EXECUTION
756 if (AcpiExTruncateFor32bitTable (ObjDesc))
757 {
758 /* Warn if we found a 64-bit constant in a 32-bit table */
759
760 ACPI_WARNING ((AE_INFO,
761 "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
762 ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
763 (UINT32) ObjDesc->Integer.Value));
764 }
765 #endif
766 break;
767
768 default:
769
770 ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
771 OpInfo->Type));
772 Status = AE_AML_OPERAND_TYPE;
773 break;
774 }
775 break;
776
777 case ACPI_TYPE_STRING:
778
779 ObjDesc->String.Pointer = Op->Common.Value.String;
780 ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String);
781
782 /*
783 * The string is contained in the ACPI table, don't ever try
784 * to delete it
785 */
786 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
787 break;
788
789 case ACPI_TYPE_METHOD:
790 break;
791
792 case ACPI_TYPE_LOCAL_REFERENCE:
793
794 switch (OpInfo->Type)
795 {
796 case AML_TYPE_LOCAL_VARIABLE:
797
798 /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
799
800 ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP;
801 ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
802
803 #ifndef ACPI_NO_METHOD_EXECUTION
804 Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
805 ObjDesc->Reference.Value, WalkState,
806 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
807 &ObjDesc->Reference.Object));
808 #endif
809 break;
810
811 case AML_TYPE_METHOD_ARGUMENT:
812
813 /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
814
815 ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP;
816 ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
817
818 #ifndef ACPI_NO_METHOD_EXECUTION
819 Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
820 ObjDesc->Reference.Value, WalkState,
821 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
822 &ObjDesc->Reference.Object));
823 #endif
824 break;
825
826 default: /* Object name or Debug object */
827
828 switch (Op->Common.AmlOpcode)
829 {
830 case AML_INT_NAMEPATH_OP:
834 ObjDesc->Reference.Node = Op->Common.Node;
835 ObjDesc->Reference.Object = Op->Common.Node->Object;
836 ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
837 break;
838
839 case AML_DEBUG_OP:
840
841 ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
842 break;
843
844 default:
845
846 ACPI_ERROR ((AE_INFO,
847 "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
848 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
849 }
850 break;
851 }
852 break;
853
854 default:
855
856 ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
857 ObjDesc->Common.Type));
858
859 Status = AE_AML_OPERAND_TYPE;
860 break;
861 }
862
863 return_ACPI_STATUS (Status);
864 }
|