1 /******************************************************************************
3 * Module Name: asloperands - AML operand processing
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
117 #include "aslcompiler.h"
118 #include "aslcompiler.y.h"
121 #define _COMPONENT ACPI_COMPILER
122 ACPI_MODULE_NAME ("asloperands")
124 /* Local prototypes */
128 ACPI_PARSE_OBJECT *Op);
132 ACPI_PARSE_OBJECT *Op);
136 ACPI_PARSE_OBJECT *Op);
139 OpnDoDefinitionBlock (
140 ACPI_PARSE_OBJECT *Op);
144 ACPI_PARSE_OBJECT *FieldOp,
145 ACPI_PARSE_OBJECT *Op);
149 ACPI_PARSE_OBJECT *Op);
153 ACPI_PARSE_OBJECT *Op);
157 ACPI_PARSE_OBJECT *Op);
161 ACPI_PARSE_OBJECT *Op);
165 ACPI_PARSE_OBJECT *Op);
168 OpnAttachNameToNode (
169 ACPI_PARSE_OBJECT *Op);
172 /*******************************************************************************
174 * FUNCTION: OpnDoMutex
176 * PARAMETERS: Op - The parent parse node
180 * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
182 ******************************************************************************/
186 ACPI_PARSE_OBJECT *Op)
188 ACPI_PARSE_OBJECT *Next;
191 Next = Op->Asl.Child;
192 Next = Next->Asl.Next;
194 if (Next->Asl.Value.Integer > 15)
196 AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
202 /*******************************************************************************
204 * FUNCTION: OpnDoMethod
206 * PARAMETERS: Op - The parent parse node
210 * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
212 ******************************************************************************/
216 ACPI_PARSE_OBJECT *Op)
218 ACPI_PARSE_OBJECT *Next;
220 /* Optional arguments for this opcode with defaults */
223 UINT8 Serialized = 0;
224 UINT8 Concurrency = 0;
228 /* Opcode and package length first */
231 Next = Op->Asl.Child;
235 Next = Next->Asl.Next;
236 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
238 NumArgs = (UINT8) Next->Asl.Value.Integer;
239 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
242 /* Serialized Flag */
244 Next = Next->Asl.Next;
245 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
247 Serialized = (UINT8) Next->Asl.Value.Integer;
248 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
251 /* Concurrency value (valid values are 0-15) */
253 Next = Next->Asl.Next;
254 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
256 /* This is a ByteConstExpr, so eval the constant now */
258 OpcAmlConstantWalk (Next, 0, NULL);
260 if (Next->Asl.Value.Integer > 15)
262 AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
264 Concurrency = (UINT8) Next->Asl.Value.Integer;
267 /* Put the bits in their proper places */
269 MethodFlags = (UINT8) ((NumArgs & 0x7) |
270 ((Serialized & 0x1) << 3) |
271 ((Concurrency & 0xF) << 4));
273 /* Use the last node for the combined flags byte */
275 Next->Asl.Value.Integer = MethodFlags;
276 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
277 Next->Asl.AmlLength = 1;
278 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
280 /* Save the arg count in the first node */
282 Op->Asl.Extra = NumArgs;
286 /*******************************************************************************
288 * FUNCTION: OpnDoFieldCommon
290 * PARAMETERS: FieldOp - Node for an ASL field
291 * Op - The parent parse node
295 * DESCRIPTION: Construct the AML operands for the various field keywords,
296 * FIELD, BANKFIELD, INDEXFIELD
298 ******************************************************************************/
302 ACPI_PARSE_OBJECT *FieldOp,
303 ACPI_PARSE_OBJECT *Op)
305 ACPI_PARSE_OBJECT *Next;
306 ACPI_PARSE_OBJECT *PkgLengthNode;
307 UINT32 CurrentBitOffset;
313 UINT32 MinimumLength;
316 /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
318 AccessType = (UINT8) Op->Asl.Value.Integer;
319 Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
321 /* Set the access type in the parent (field) node for use later */
323 FieldOp->Asl.Value.Integer = AccessType;
325 /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
328 LockRule = (UINT8) Next->Asl.Value.Integer;
329 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
331 /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
333 Next = Next->Asl.Next;
334 UpdateRule = (UINT8) Next->Asl.Value.Integer;
337 * Generate the flags byte. The various fields are already
338 * in the right bit position via translation from the
339 * keywords by the parser.
341 FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule);
343 /* Use the previous node to be the FieldFlags node */
345 /* Set the node to RAW_DATA */
347 Next->Asl.Value.Integer = FieldFlags;
348 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
349 Next->Asl.AmlLength = 1;
350 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
352 /* Process the FieldUnitList */
354 Next = Next->Asl.Next;
355 CurrentBitOffset = 0;
359 /* Save the offset of this field unit */
361 Next->Asl.ExtraValue = CurrentBitOffset;
363 switch (Next->Asl.ParseOpcode)
365 case PARSEOP_ACCESSAS:
367 PkgLengthNode = Next->Asl.Child;
368 AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer;
370 /* Nothing additional to do */
376 /* New offset into the field */
378 PkgLengthNode = Next->Asl.Child;
379 NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8;
382 * Examine the specified offset in relation to the
383 * current offset counter.
385 if (NewBitOffset < CurrentBitOffset)
388 * Not allowed to specify a backwards offset!
389 * Issue error and ignore this node.
391 AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode,
393 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
394 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
396 else if (NewBitOffset == CurrentBitOffset)
399 * Offset is redundant; we don't need to output an
400 * offset opcode. Just set these nodes to default
402 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
403 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
408 * Valid new offset - set the value to be inserted into the AML
409 * and update the offset counter.
411 PkgLengthNode->Asl.Value.Integer =
412 NewBitOffset - CurrentBitOffset;
413 CurrentBitOffset = NewBitOffset;
418 case PARSEOP_NAMESEG:
419 case PARSEOP_RESERVED_BYTES:
421 /* Named or reserved field entry */
423 PkgLengthNode = Next->Asl.Child;
424 NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer;
425 CurrentBitOffset += NewBitOffset;
427 /* Save the current AccessAs value for error checking later */
431 case AML_FIELD_ACCESS_ANY:
432 case AML_FIELD_ACCESS_BYTE:
433 case AML_FIELD_ACCESS_BUFFER:
438 case AML_FIELD_ACCESS_WORD:
442 case AML_FIELD_ACCESS_DWORD:
446 case AML_FIELD_ACCESS_QWORD:
451 PkgLengthNode->Asl.ExtraValue = MinimumLength;
455 /* All supported field opcodes must appear above */
459 /* Move on to next entry in the field list */
461 Next = Next->Asl.Next;
466 /*******************************************************************************
468 * FUNCTION: OpnDoField
470 * PARAMETERS: Op - The parent parse node
474 * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
476 ******************************************************************************/
480 ACPI_PARSE_OBJECT *Op)
482 ACPI_PARSE_OBJECT *Next;
485 /* Opcode is parent node */
486 /* First child is field name */
488 Next = Op->Asl.Child;
490 /* Second child is the AccessType */
492 OpnDoFieldCommon (Op, Next->Asl.Next);
496 /*******************************************************************************
498 * FUNCTION: OpnDoIndexField
500 * PARAMETERS: Op - The parent parse node
504 * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
506 ******************************************************************************/
510 ACPI_PARSE_OBJECT *Op)
512 ACPI_PARSE_OBJECT *Next;
515 /* Opcode is parent node */
516 /* First child is the index name */
518 Next = Op->Asl.Child;
520 /* Second child is the data name */
522 Next = Next->Asl.Next;
524 /* Third child is the AccessType */
526 OpnDoFieldCommon (Op, Next->Asl.Next);
530 /*******************************************************************************
532 * FUNCTION: OpnDoBankField
534 * PARAMETERS: Op - The parent parse node
538 * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
540 ******************************************************************************/
544 ACPI_PARSE_OBJECT *Op)
546 ACPI_PARSE_OBJECT *Next;
549 /* Opcode is parent node */
550 /* First child is the region name */
552 Next = Op->Asl.Child;
554 /* Second child is the bank name */
556 Next = Next->Asl.Next;
558 /* Third child is the bank value */
560 Next = Next->Asl.Next;
562 /* Fourth child is the AccessType */
564 OpnDoFieldCommon (Op, Next->Asl.Next);
568 /*******************************************************************************
570 * FUNCTION: OpnDoRegion
572 * PARAMETERS: Op - The parent parse node
576 * DESCRIPTION: Tries to get the length of the region. Can only do this at
577 * compile time if the length is a constant.
579 ******************************************************************************/
583 ACPI_PARSE_OBJECT *Op)
585 ACPI_PARSE_OBJECT *Next;
588 /* Opcode is parent node */
589 /* First child is the region name */
591 Next = Op->Asl.Child;
593 /* Second child is the space ID*/
595 Next = Next->Asl.Next;
597 /* Third child is the region offset */
599 Next = Next->Asl.Next;
601 /* Fourth child is the region length */
603 Next = Next->Asl.Next;
604 if (Next->Asl.ParseOpcode == PARSEOP_INTEGER)
606 Op->Asl.Value.Integer = Next->Asl.Value.Integer;
610 Op->Asl.Value.Integer = ACPI_UINT64_MAX;
615 /*******************************************************************************
617 * FUNCTION: OpnDoBuffer
619 * PARAMETERS: Op - The parent parse node
623 * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
624 * build a single raw byte buffer from the initialization nodes,
625 * each parse node contains a buffer byte.
627 ******************************************************************************/
631 ACPI_PARSE_OBJECT *Op)
633 ACPI_PARSE_OBJECT *InitializerOp;
634 ACPI_PARSE_OBJECT *BufferLengthOp;
636 /* Optional arguments for this opcode with defaults */
638 UINT32 BufferLength = 0;
641 /* Opcode and package length first */
642 /* Buffer Length is next, followed by the initializer list */
644 BufferLengthOp = Op->Asl.Child;
645 InitializerOp = BufferLengthOp->Asl.Next;
648 * If the BufferLength is not an INTEGER or was not specified in the ASL
649 * (DEFAULT_ARG), it is a TermArg that is
650 * evaluated at run-time, and we are therefore finished.
652 if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
653 (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
659 * We want to count the number of items in the initializer list, because if
660 * it is larger than the buffer length, we will define the buffer size
661 * to be the size of the initializer list (as per the ACPI Specification)
663 switch (InitializerOp->Asl.ParseOpcode)
665 case PARSEOP_INTEGER:
666 case PARSEOP_BYTECONST:
667 case PARSEOP_WORDCONST:
668 case PARSEOP_DWORDCONST:
670 /* The peer list contains the byte list (if any...) */
672 while (InitializerOp)
674 /* For buffers, this is a list of raw bytes */
676 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
677 InitializerOp->Asl.AmlLength = 1;
678 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
681 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
686 case PARSEOP_STRING_LITERAL:
689 * Only one initializer, the string. Buffer must be big enough to hold
690 * the string plus the null termination byte
692 BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
694 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
695 InitializerOp->Asl.AmlLength = BufferLength;
696 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
700 case PARSEOP_RAW_DATA:
702 /* Buffer nodes are already initialized (e.g. Unicode operator) */
706 case PARSEOP_DEFAULT_ARG:
711 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
712 "Unknown buffer initializer opcode");
713 printf ("Unknown buffer initializer opcode [%s]\n",
714 UtGetOpName (InitializerOp->Asl.ParseOpcode));
718 /* Check if initializer list is longer than the buffer length */
720 if (BufferLengthOp->Asl.Value.Integer > BufferLength)
722 BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
727 /* No length AND no items -- issue notice */
729 AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
731 /* But go ahead and put the buffer length of zero into the AML */
735 * Just set the buffer size node to be the buffer length, regardless
736 * of whether it was previously an integer or a default_arg placeholder
738 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
739 BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
740 BufferLengthOp->Asl.Value.Integer = BufferLength;
742 (void) OpcSetOptimalIntegerSize (BufferLengthOp);
744 /* Remaining nodes are handled via the tree walk */
748 /*******************************************************************************
750 * FUNCTION: OpnDoPackage
752 * PARAMETERS: Op - The parent parse node
756 * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
757 * can only be called after constants have been folded, to ensure
758 * that the PackageLength operand has been fully reduced.
760 ******************************************************************************/
764 ACPI_PARSE_OBJECT *Op)
766 ACPI_PARSE_OBJECT *InitializerOp;
767 ACPI_PARSE_OBJECT *PackageLengthOp;
768 UINT32 PackageLength = 0;
771 /* Opcode and package length first, followed by the initializer list */
773 PackageLengthOp = Op->Asl.Child;
774 InitializerOp = PackageLengthOp->Asl.Next;
776 /* Count the number of items in the initializer list */
778 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
780 /* The peer list contains the byte list (if any...) */
782 while (InitializerOp)
785 InitializerOp = InitializerOp->Asl.Next;
789 /* If package length is a constant, compare to the initializer list */
791 if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
792 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST))
794 if (PackageLengthOp->Asl.Value.Integer > PackageLength)
797 * Allow package length to be longer than the initializer
798 * list -- but if the length of initializer list is nonzero,
799 * issue a message since this is probably a coding error,
800 * even though technically legal.
802 if (PackageLength > 0)
804 AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT,
805 PackageLengthOp, NULL);
808 PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer;
810 else if (PackageLengthOp->Asl.Value.Integer < PackageLength)
813 * The package length is smaller than the length of the
814 * initializer list. This is an error as per the ACPI spec.
816 AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG,
817 PackageLengthOp, NULL);
821 if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
824 * This is the case if the PackageLength was left empty - Package()
825 * The package length becomes the length of the initializer list
827 Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
828 Op->Asl.Child->Asl.Value.Integer = PackageLength;
830 /* Set the AML opcode */
832 (void) OpcSetOptimalIntegerSize (Op->Asl.Child);
835 /* If not a variable-length package, check for a zero package length */
837 if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
838 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) ||
839 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_ZERO) ||
840 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
844 /* No length AND no initializer list -- issue a remark */
846 AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH,
847 PackageLengthOp, NULL);
849 /* But go ahead and put the buffer length of zero into the AML */
854 * If the PackageLength is a constant <= 255, we can change the
855 * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
857 if (((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
858 (Op->Asl.Child->Asl.Value.Integer <= 255)) ||
859 (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONE) ||
860 (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONES)||
861 (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ZERO))
863 Op->Asl.AmlOpcode = AML_PACKAGE_OP;
864 Op->Asl.ParseOpcode = PARSEOP_PACKAGE;
867 * Just set the package size node to be the package length, regardless
868 * of whether it was previously an integer or a default_arg placeholder
870 PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
871 PackageLengthOp->Asl.AmlLength = 1;
872 PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
873 PackageLengthOp->Asl.Value.Integer = PackageLength;
876 /* Remaining nodes are handled via the tree walk */
880 /*******************************************************************************
882 * FUNCTION: OpnDoLoadTable
884 * PARAMETERS: Op - The parent parse node
888 * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
890 ******************************************************************************/
894 ACPI_PARSE_OBJECT *Op)
896 ACPI_PARSE_OBJECT *Next;
899 /* Opcode is parent node */
900 /* First child is the table signature */
902 Next = Op->Asl.Child;
904 /* Second child is the OEM ID*/
906 Next = Next->Asl.Next;
908 /* Third child is the OEM table ID */
910 Next = Next->Asl.Next;
912 /* Fourth child is the RootPath string */
914 Next = Next->Asl.Next;
915 if (Next->Asl.ParseOpcode == PARSEOP_ZERO)
917 Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
918 Next->Asl.Value.String = "\\";
919 Next->Asl.AmlLength = 2;
920 OpcGenerateAmlOpcode (Next);
923 #ifdef ASL_FUTURE_IMPLEMENTATION
925 /* TBD: NOT IMPLEMENTED */
926 /* Fifth child is the [optional] ParameterPathString */
927 /* Sixth child is the [optional] ParameterData */
929 Next = Next->Asl.Next;
930 if (Next->Asl.ParseOpcode == DEFAULT_ARG)
932 Next->Asl.AmlLength = 1;
933 Next->Asl.ParseOpcode = ZERO;
934 OpcGenerateAmlOpcode (Next);
938 Next = Next->Asl.Next;
939 if (Next->Asl.ParseOpcode == DEFAULT_ARG)
941 Next->Asl.AmlLength = 1;
942 Next->Asl.ParseOpcode = ZERO;
943 OpcGenerateAmlOpcode (Next);
949 /*******************************************************************************
951 * FUNCTION: OpnDoDefinitionBlock
953 * PARAMETERS: Op - The parent parse node
957 * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
959 ******************************************************************************/
962 OpnDoDefinitionBlock (
963 ACPI_PARSE_OBJECT *Op)
965 ACPI_PARSE_OBJECT *Child;
972 * These nodes get stuffed into the table header. They are special
973 * cased when the table is written to the output file.
975 * Mark all of these nodes as non-usable so they won't get output
979 /* Get AML filename. Use it if non-null */
981 Child = Op->Asl.Child;
982 if (Child->Asl.Value.Buffer &&
983 *Child->Asl.Value.Buffer &&
984 (Gbl_UseDefaultAmlFilename))
987 * We will use the AML filename that is embedded in the source file
988 * for the output filename.
990 Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) +
991 strlen ((char *) Child->Asl.Value.Buffer) + 1);
993 /* Prepend the current directory path */
995 strcpy (Filename, Gbl_DirectoryPath);
996 strcat (Filename, (char *) Child->Asl.Value.Buffer);
998 Gbl_OutputFilenamePrefix = Filename;
1000 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1004 Child = Child->Asl.Next;
1005 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1006 if (Child->Asl.Value.String)
1008 Gbl_TableSignature = Child->Asl.Value.String;
1009 if (ACPI_STRLEN (Gbl_TableSignature) != 4)
1011 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
1012 "Length not exactly 4");
1015 for (i = 0; i < 4; i++)
1017 if (!isalnum ((int) Gbl_TableSignature[i]))
1019 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
1020 "Contains non-alphanumeric characters");
1027 Child = Child->Asl.Next;
1028 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1030 * We used the revision to set the integer width earlier
1035 Child = Child->Asl.Next;
1036 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1040 Child = Child->Asl.Next;
1041 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1042 if (Child->Asl.Value.String)
1044 Length = ACPI_STRLEN (Child->Asl.Value.String);
1045 Gbl_TableId = AcpiOsAllocate (Length + 1);
1046 ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
1048 for (i = 0; i < Length; i++)
1050 if (Gbl_TableId[i] == ' ')
1060 Child = Child->Asl.Next;
1061 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
1065 /*******************************************************************************
1067 * FUNCTION: UtGetArg
1069 * PARAMETERS: Op - Get an argument for this op
1070 * Argn - Nth argument to get
1072 * RETURN: The argument (as an Op object). NULL if argument does not exist
1074 * DESCRIPTION: Get the specified op's argument (peer)
1076 ******************************************************************************/
1080 ACPI_PARSE_OBJECT *Op,
1083 ACPI_PARSE_OBJECT *Arg = NULL;
1086 /* Get the requested argument object */
1088 Arg = Op->Asl.Child;
1092 Arg = Arg->Asl.Next;
1099 /*******************************************************************************
1101 * FUNCTION: OpnAttachNameToNode
1103 * PARAMETERS: Op - The parent parse node
1107 * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1108 * argument list and attach it to the parent node so that we
1109 * can get to it quickly later.
1111 ******************************************************************************/
1114 OpnAttachNameToNode (
1115 ACPI_PARSE_OBJECT *Op)
1117 ACPI_PARSE_OBJECT *Child = NULL;
1120 if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)
1122 Child = UtGetArg (Op, 0);
1124 else switch (Op->Asl.AmlOpcode)
1126 case AML_DATA_REGION_OP:
1132 case AML_POWER_RES_OP:
1133 case AML_PROCESSOR_OP:
1134 case AML_THERMAL_ZONE_OP:
1138 Child = UtGetArg (Op, 0);
1143 Child = UtGetArg (Op, 1);
1146 case AML_CREATE_BIT_FIELD_OP:
1147 case AML_CREATE_BYTE_FIELD_OP:
1148 case AML_CREATE_WORD_FIELD_OP:
1149 case AML_CREATE_DWORD_FIELD_OP:
1150 case AML_CREATE_QWORD_FIELD_OP:
1152 Child = UtGetArg (Op, 2);
1155 case AML_CREATE_FIELD_OP:
1157 Child = UtGetArg (Op, 3);
1160 case AML_BANK_FIELD_OP:
1161 case AML_INDEX_FIELD_OP:
1172 UtAttachNamepathToOwner (Op, Child);
1177 /*******************************************************************************
1179 * FUNCTION: OpnGenerateAmlOperands
1181 * PARAMETERS: Op - The parent parse node
1185 * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
1186 * complex AML opcodes require processing of the child nodes
1187 * (arguments/operands).
1189 ******************************************************************************/
1192 OpnGenerateAmlOperands (
1193 ACPI_PARSE_OBJECT *Op)
1197 if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
1202 switch (Op->Asl.ParseOpcode)
1204 case PARSEOP_DEFINITIONBLOCK:
1205 OpnDoDefinitionBlock (Op);
1208 case PARSEOP_METHOD:
1220 case PARSEOP_INDEXFIELD:
1221 OpnDoIndexField (Op);
1224 case PARSEOP_BANKFIELD:
1225 OpnDoBankField (Op);
1228 case PARSEOP_BUFFER:
1232 case PARSEOP_LOADTABLE:
1233 OpnDoLoadTable (Op);
1236 case PARSEOP_OPERATIONREGION:
1240 case PARSEOP_RESOURCETEMPLATE:
1241 RsDoResourceTemplate (Op);
1244 case PARSEOP_NAMESEG:
1245 case PARSEOP_NAMESTRING:
1246 case PARSEOP_METHODCALL:
1247 case PARSEOP_STRING_LITERAL:
1256 OpnAttachNameToNode (Op);