2 /******************************************************************************
4 * Module Name: asloperands - AML operand processing
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
14 * All rights reserved.
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
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
74 * 3.4. Intel retains all right, title, and interest in and to the Original
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
119 #include "aslcompiler.h"
120 #include "aslcompiler.y.h"
123 #define _COMPONENT ACPI_COMPILER
124 ACPI_MODULE_NAME ("asloperands")
126 /* Local prototypes */
130 ACPI_PARSE_OBJECT
*Op
);
134 ACPI_PARSE_OBJECT
*Op
);
138 ACPI_PARSE_OBJECT
*Op
);
141 OpnDoDefinitionBlock (
142 ACPI_PARSE_OBJECT
*Op
);
146 ACPI_PARSE_OBJECT
*FieldOp
,
147 ACPI_PARSE_OBJECT
*Op
);
151 ACPI_PARSE_OBJECT
*Op
);
155 ACPI_PARSE_OBJECT
*Op
);
159 ACPI_PARSE_OBJECT
*Op
);
163 ACPI_PARSE_OBJECT
*Op
);
167 ACPI_PARSE_OBJECT
*Op
);
170 OpnAttachNameToNode (
171 ACPI_PARSE_OBJECT
*Op
);
174 /*******************************************************************************
176 * FUNCTION: OpnDoMutex
178 * PARAMETERS: Op - The parent parse node
182 * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
184 ******************************************************************************/
188 ACPI_PARSE_OBJECT
*Op
)
190 ACPI_PARSE_OBJECT
*Next
;
193 Next
= Op
->Asl
.Child
;
194 Next
= Next
->Asl
.Next
;
196 if (Next
->Asl
.Value
.Integer
> 15)
198 AslError (ASL_ERROR
, ASL_MSG_SYNC_LEVEL
, Next
, NULL
);
204 /*******************************************************************************
206 * FUNCTION: OpnDoMethod
208 * PARAMETERS: Op - The parent parse node
212 * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
214 ******************************************************************************/
218 ACPI_PARSE_OBJECT
*Op
)
220 ACPI_PARSE_OBJECT
*Next
;
222 /* Optional arguments for this opcode with defaults */
225 UINT8 Serialized
= 0;
226 UINT8 Concurrency
= 0;
230 /* Opcode and package length first */
233 Next
= Op
->Asl
.Child
;
237 Next
= Next
->Asl
.Next
;
238 if (Next
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
240 NumArgs
= (UINT8
) Next
->Asl
.Value
.Integer
;
241 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
244 /* Serialized Flag */
246 Next
= Next
->Asl
.Next
;
247 if (Next
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
249 Serialized
= (UINT8
) Next
->Asl
.Value
.Integer
;
250 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
253 /* Concurrency value (valid values are 0-15) */
255 Next
= Next
->Asl
.Next
;
256 if (Next
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
258 if (Next
->Asl
.Value
.Integer
> 15)
260 AslError (ASL_ERROR
, ASL_MSG_SYNC_LEVEL
, Next
, NULL
);
262 Concurrency
= (UINT8
) Next
->Asl
.Value
.Integer
;
265 /* Put the bits in their proper places */
267 MethodFlags
= (UINT8
) ((NumArgs
& 0x7) |
268 ((Serialized
& 0x1) << 3) |
269 ((Concurrency
& 0xF) << 4));
271 /* Use the last node for the combined flags byte */
273 Next
->Asl
.Value
.Integer
= MethodFlags
;
274 Next
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
275 Next
->Asl
.AmlLength
= 1;
276 Next
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
278 /* Save the arg count in the first node */
280 Op
->Asl
.Extra
= NumArgs
;
284 /*******************************************************************************
286 * FUNCTION: OpnDoFieldCommon
288 * PARAMETERS: FieldOp - Node for an ASL field
289 * Op - The parent parse node
293 * DESCRIPTION: Construct the AML operands for the various field keywords,
294 * FIELD, BANKFIELD, INDEXFIELD
296 ******************************************************************************/
300 ACPI_PARSE_OBJECT
*FieldOp
,
301 ACPI_PARSE_OBJECT
*Op
)
303 ACPI_PARSE_OBJECT
*Next
;
304 ACPI_PARSE_OBJECT
*PkgLengthNode
;
305 UINT32 CurrentBitOffset
;
311 UINT32 MinimumLength
;
314 /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
316 AccessType
= (UINT8
) Op
->Asl
.Value
.Integer
;
317 Op
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
319 /* Set the access type in the parent (field) node for use later */
321 FieldOp
->Asl
.Value
.Integer
= AccessType
;
323 /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
326 LockRule
= (UINT8
) Next
->Asl
.Value
.Integer
;
327 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
329 /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
331 Next
= Next
->Asl
.Next
;
332 UpdateRule
= (UINT8
) Next
->Asl
.Value
.Integer
;
335 * Generate the flags byte. The various fields are already
336 * in the right bit position via translation from the
337 * keywords by the parser.
339 FieldFlags
= (UINT8
) (AccessType
| LockRule
| UpdateRule
);
341 /* Use the previous node to be the FieldFlags node */
343 /* Set the node to RAW_DATA */
345 Next
->Asl
.Value
.Integer
= FieldFlags
;
346 Next
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
347 Next
->Asl
.AmlLength
= 1;
348 Next
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
350 /* Process the FieldUnitList */
352 Next
= Next
->Asl
.Next
;
353 CurrentBitOffset
= 0;
357 /* Save the offset of this field unit */
359 Next
->Asl
.ExtraValue
= CurrentBitOffset
;
361 switch (Next
->Asl
.ParseOpcode
)
363 case PARSEOP_ACCESSAS
:
365 PkgLengthNode
= Next
->Asl
.Child
;
366 AccessType
= (UINT8
) PkgLengthNode
->Asl
.Value
.Integer
;
368 /* Nothing additional to do */
374 /* New offset into the field */
376 PkgLengthNode
= Next
->Asl
.Child
;
377 NewBitOffset
= ((UINT32
) PkgLengthNode
->Asl
.Value
.Integer
) * 8;
380 * Examine the specified offset in relation to the
381 * current offset counter.
383 if (NewBitOffset
< CurrentBitOffset
)
386 * Not allowed to specify a backwards offset!
387 * Issue error and ignore this node.
389 AslError (ASL_ERROR
, ASL_MSG_BACKWARDS_OFFSET
, PkgLengthNode
,
391 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
392 PkgLengthNode
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
394 else if (NewBitOffset
== CurrentBitOffset
)
397 * Offset is redundant; we don't need to output an
398 * offset opcode. Just set these nodes to default
400 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
401 PkgLengthNode
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
406 * Valid new offset - set the value to be inserted into the AML
407 * and update the offset counter.
409 PkgLengthNode
->Asl
.Value
.Integer
=
410 NewBitOffset
- CurrentBitOffset
;
411 CurrentBitOffset
= NewBitOffset
;
416 case PARSEOP_NAMESEG
:
417 case PARSEOP_RESERVED_BYTES
:
419 /* Named or reserved field entry */
421 PkgLengthNode
= Next
->Asl
.Child
;
422 NewBitOffset
= (UINT32
) PkgLengthNode
->Asl
.Value
.Integer
;
423 CurrentBitOffset
+= NewBitOffset
;
425 /* Save the current AccessAs value for error checking later */
429 case AML_FIELD_ACCESS_ANY
:
430 case AML_FIELD_ACCESS_BYTE
:
431 case AML_FIELD_ACCESS_BUFFER
:
436 case AML_FIELD_ACCESS_WORD
:
440 case AML_FIELD_ACCESS_DWORD
:
444 case AML_FIELD_ACCESS_QWORD
:
449 PkgLengthNode
->Asl
.ExtraValue
= MinimumLength
;
453 /* All supported field opcodes must appear above */
457 /* Move on to next entry in the field list */
459 Next
= Next
->Asl
.Next
;
464 /*******************************************************************************
466 * FUNCTION: OpnDoField
468 * PARAMETERS: Op - The parent parse node
472 * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
474 ******************************************************************************/
478 ACPI_PARSE_OBJECT
*Op
)
480 ACPI_PARSE_OBJECT
*Next
;
483 /* Opcode is parent node */
484 /* First child is field name */
486 Next
= Op
->Asl
.Child
;
488 /* Second child is the AccessType */
490 OpnDoFieldCommon (Op
, Next
->Asl
.Next
);
494 /*******************************************************************************
496 * FUNCTION: OpnDoIndexField
498 * PARAMETERS: Op - The parent parse node
502 * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
504 ******************************************************************************/
508 ACPI_PARSE_OBJECT
*Op
)
510 ACPI_PARSE_OBJECT
*Next
;
513 /* Opcode is parent node */
514 /* First child is the index name */
516 Next
= Op
->Asl
.Child
;
518 /* Second child is the data name */
520 Next
= Next
->Asl
.Next
;
522 /* Third child is the AccessType */
524 OpnDoFieldCommon (Op
, Next
->Asl
.Next
);
528 /*******************************************************************************
530 * FUNCTION: OpnDoBankField
532 * PARAMETERS: Op - The parent parse node
536 * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
538 ******************************************************************************/
542 ACPI_PARSE_OBJECT
*Op
)
544 ACPI_PARSE_OBJECT
*Next
;
547 /* Opcode is parent node */
548 /* First child is the region name */
550 Next
= Op
->Asl
.Child
;
552 /* Second child is the bank name */
554 Next
= Next
->Asl
.Next
;
556 /* Third child is the bank value */
558 Next
= Next
->Asl
.Next
;
560 /* Fourth child is the AccessType */
562 OpnDoFieldCommon (Op
, Next
->Asl
.Next
);
566 /*******************************************************************************
568 * FUNCTION: OpnDoRegion
570 * PARAMETERS: Op - The parent parse node
574 * DESCRIPTION: Tries to get the length of the region. Can only do this at
575 * compile time if the length is a constant.
577 ******************************************************************************/
581 ACPI_PARSE_OBJECT
*Op
)
583 ACPI_PARSE_OBJECT
*Next
;
586 /* Opcode is parent node */
587 /* First child is the region name */
589 Next
= Op
->Asl
.Child
;
591 /* Second child is the space ID*/
593 Next
= Next
->Asl
.Next
;
595 /* Third child is the region offset */
597 Next
= Next
->Asl
.Next
;
599 /* Fourth child is the region length */
601 Next
= Next
->Asl
.Next
;
602 if (Next
->Asl
.ParseOpcode
== PARSEOP_INTEGER
)
604 Op
->Asl
.Value
.Integer
= Next
->Asl
.Value
.Integer
;
608 Op
->Asl
.Value
.Integer
= ACPI_INTEGER_MAX
;
613 /*******************************************************************************
615 * FUNCTION: OpnDoBuffer
617 * PARAMETERS: Op - The parent parse node
621 * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
622 * build a single raw byte buffer from the initialization nodes,
623 * each parse node contains a buffer byte.
625 ******************************************************************************/
629 ACPI_PARSE_OBJECT
*Op
)
631 ACPI_PARSE_OBJECT
*InitializerOp
;
632 ACPI_PARSE_OBJECT
*BufferLengthOp
;
634 /* Optional arguments for this opcode with defaults */
636 UINT32 BufferLength
= 0;
639 /* Opcode and package length first */
640 /* Buffer Length is next, followed by the initializer list */
642 BufferLengthOp
= Op
->Asl
.Child
;
643 InitializerOp
= BufferLengthOp
->Asl
.Next
;
646 * If the BufferLength is not an INTEGER or was not specified in the ASL
647 * (DEFAULT_ARG), it is a TermArg that is
648 * evaluated at run-time, and we are therefore finished.
650 if ((BufferLengthOp
->Asl
.ParseOpcode
!= PARSEOP_INTEGER
) &&
651 (BufferLengthOp
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
))
657 * We want to count the number of items in the initializer list, because if
658 * it is larger than the buffer length, we will define the buffer size
659 * to be the size of the initializer list (as per the ACPI Specification)
661 switch (InitializerOp
->Asl
.ParseOpcode
)
663 case PARSEOP_INTEGER
:
664 case PARSEOP_BYTECONST
:
665 case PARSEOP_WORDCONST
:
666 case PARSEOP_DWORDCONST
:
668 /* The peer list contains the byte list (if any...) */
670 while (InitializerOp
)
672 /* For buffers, this is a list of raw bytes */
674 InitializerOp
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
675 InitializerOp
->Asl
.AmlLength
= 1;
676 InitializerOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
679 InitializerOp
= ASL_GET_PEER_NODE (InitializerOp
);
684 case PARSEOP_STRING_LITERAL
:
687 * Only one initializer, the string. Buffer must be big enough to hold
688 * the string plus the null termination byte
690 BufferLength
= strlen (InitializerOp
->Asl
.Value
.String
) + 1;
692 InitializerOp
->Asl
.AmlOpcode
= AML_RAW_DATA_BUFFER
;
693 InitializerOp
->Asl
.AmlLength
= BufferLength
;
694 InitializerOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
698 case PARSEOP_RAW_DATA
:
700 /* Buffer nodes are already initialized (e.g. Unicode operator) */
704 case PARSEOP_DEFAULT_ARG
:
709 AslError (ASL_ERROR
, ASL_MSG_INVALID_OPERAND
, InitializerOp
,
710 "Unknown buffer initializer opcode");
711 printf ("Unknown buffer initializer opcode [%s]\n",
712 UtGetOpName (InitializerOp
->Asl
.ParseOpcode
));
716 /* Check if initializer list is longer than the buffer length */
718 if (BufferLengthOp
->Asl
.Value
.Integer
> BufferLength
)
720 BufferLength
= (UINT32
) BufferLengthOp
->Asl
.Value
.Integer
;
725 /* No length AND no items -- issue notice */
727 AslError (ASL_REMARK
, ASL_MSG_BUFFER_LENGTH
, BufferLengthOp
, NULL
);
729 /* But go ahead and put the buffer length of zero into the AML */
733 * Just set the buffer size node to be the buffer length, regardless
734 * of whether it was previously an integer or a default_arg placeholder
736 BufferLengthOp
->Asl
.ParseOpcode
= PARSEOP_INTEGER
;
737 BufferLengthOp
->Asl
.AmlOpcode
= AML_DWORD_OP
;
738 BufferLengthOp
->Asl
.Value
.Integer
= BufferLength
;
740 (void) OpcSetOptimalIntegerSize (BufferLengthOp
);
742 /* Remaining nodes are handled via the tree walk */
746 /*******************************************************************************
748 * FUNCTION: OpnDoPackage
750 * PARAMETERS: Op - The parent parse node
754 * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
755 * can only be called after constants have been folded, to ensure
756 * that the PackageLength operand has been fully reduced.
758 ******************************************************************************/
762 ACPI_PARSE_OBJECT
*Op
)
764 ACPI_PARSE_OBJECT
*InitializerOp
;
765 ACPI_PARSE_OBJECT
*PackageLengthOp
;
766 UINT32 PackageLength
= 0;
769 /* Opcode and package length first, followed by the initializer list */
771 PackageLengthOp
= Op
->Asl
.Child
;
772 InitializerOp
= PackageLengthOp
->Asl
.Next
;
774 /* Count the number of items in the initializer list */
776 if (InitializerOp
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
778 /* The peer list contains the byte list (if any...) */
780 while (InitializerOp
)
783 InitializerOp
= InitializerOp
->Asl
.Next
;
787 /* If package length is a constant, compare to the initializer list */
789 if ((PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) ||
790 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_QWORDCONST
))
792 if (PackageLengthOp
->Asl
.Value
.Integer
>= PackageLength
)
794 /* Allow package to be longer than the initializer list */
796 PackageLength
= (UINT32
) PackageLengthOp
->Asl
.Value
.Integer
;
801 * Initializer list is longer than the package length. This
802 * is an error as per the ACPI spec.
804 AslError (ASL_ERROR
, ASL_MSG_LIST_LENGTH
,
805 PackageLengthOp
->Asl
.Next
, NULL
);
809 if (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
)
812 * This is the case if the PackageLength was left empty - Package()
813 * The package length becomes the length of the initializer list
815 Op
->Asl
.Child
->Asl
.ParseOpcode
= PARSEOP_INTEGER
;
816 Op
->Asl
.Child
->Asl
.Value
.Integer
= PackageLength
;
818 /* Set the AML opcode */
820 (void) OpcSetOptimalIntegerSize (Op
->Asl
.Child
);
823 /* If not a variable-length package, check for a zero package length */
825 if ((PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) ||
826 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_QWORDCONST
) ||
827 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
))
831 /* No length AND no initializer list -- issue a remark */
833 AslError (ASL_REMARK
, ASL_MSG_PACKAGE_LENGTH
,
834 PackageLengthOp
, NULL
);
836 /* But go ahead and put the buffer length of zero into the AML */
841 * If the PackageLength is a constant <= 255, we can change the
842 * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
844 if ((Op
->Asl
.Child
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) &&
845 (Op
->Asl
.Child
->Asl
.Value
.Integer
<= 255))
847 Op
->Asl
.AmlOpcode
= AML_PACKAGE_OP
;
848 Op
->Asl
.ParseOpcode
= PARSEOP_PACKAGE
;
851 * Just set the package size node to be the package length, regardless
852 * of whether it was previously an integer or a default_arg placeholder
854 PackageLengthOp
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
855 PackageLengthOp
->Asl
.AmlLength
= 1;
856 PackageLengthOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
857 PackageLengthOp
->Asl
.Value
.Integer
= PackageLength
;
860 /* Remaining nodes are handled via the tree walk */
864 /*******************************************************************************
866 * FUNCTION: OpnDoLoadTable
868 * PARAMETERS: Op - The parent parse node
872 * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
874 ******************************************************************************/
878 ACPI_PARSE_OBJECT
*Op
)
880 ACPI_PARSE_OBJECT
*Next
;
883 /* Opcode is parent node */
884 /* First child is the table signature */
886 Next
= Op
->Asl
.Child
;
888 /* Second child is the OEM ID*/
890 Next
= Next
->Asl
.Next
;
892 /* Third child is the OEM table ID */
894 Next
= Next
->Asl
.Next
;
896 /* Fourth child is the RootPath string */
898 Next
= Next
->Asl
.Next
;
899 if (Next
->Asl
.ParseOpcode
== PARSEOP_ZERO
)
901 Next
->Asl
.ParseOpcode
= PARSEOP_STRING_LITERAL
;
902 Next
->Asl
.Value
.String
= "\\";
903 Next
->Asl
.AmlLength
= 2;
904 OpcGenerateAmlOpcode (Next
);
907 #ifdef ASL_FUTURE_IMPLEMENTATION
909 /* TBD: NOT IMPLEMENTED */
910 /* Fifth child is the [optional] ParameterPathString */
911 /* Sixth child is the [optional] ParameterData */
913 Next
= Next
->Asl
.Next
;
914 if (Next
->Asl
.ParseOpcode
== DEFAULT_ARG
)
916 Next
->Asl
.AmlLength
= 1;
917 Next
->Asl
.ParseOpcode
= ZERO
;
918 OpcGenerateAmlOpcode (Next
);
922 Next
= Next
->Asl
.Next
;
923 if (Next
->Asl
.ParseOpcode
== DEFAULT_ARG
)
925 Next
->Asl
.AmlLength
= 1;
926 Next
->Asl
.ParseOpcode
= ZERO
;
927 OpcGenerateAmlOpcode (Next
);
933 /*******************************************************************************
935 * FUNCTION: OpnDoDefinitionBlock
937 * PARAMETERS: Op - The parent parse node
941 * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
943 ******************************************************************************/
946 OpnDoDefinitionBlock (
947 ACPI_PARSE_OBJECT
*Op
)
949 ACPI_PARSE_OBJECT
*Child
;
955 * These nodes get stuffed into the table header. They are special
956 * cased when the table is written to the output file.
958 * Mark all of these nodes as non-usable so they won't get output
962 /* Get AML filename. Use it if non-null */
964 Child
= Op
->Asl
.Child
;
965 if (Child
->Asl
.Value
.Buffer
&&
966 *Child
->Asl
.Value
.Buffer
&&
967 (Gbl_UseDefaultAmlFilename
))
969 Gbl_OutputFilenamePrefix
= (char *) Child
->Asl
.Value
.Buffer
;
971 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
975 Child
= Child
->Asl
.Next
;
976 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
977 if (Child
->Asl
.Value
.String
)
979 Gbl_TableSignature
= Child
->Asl
.Value
.String
;
980 if (ACPI_STRLEN (Gbl_TableSignature
) != 4)
982 AslError (ASL_ERROR
, ASL_MSG_TABLE_SIGNATURE
, Child
,
983 "Length not exactly 4");
986 for (i
= 0; i
< 4; i
++)
988 if (!isalnum (Gbl_TableSignature
[i
]))
990 AslError (ASL_ERROR
, ASL_MSG_TABLE_SIGNATURE
, Child
,
991 "Contains non-alphanumeric characters");
998 Child
= Child
->Asl
.Next
;
999 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
1001 * We used the revision to set the integer width earlier
1006 Child
= Child
->Asl
.Next
;
1007 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
1011 Child
= Child
->Asl
.Next
;
1012 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
1013 if (Child
->Asl
.Value
.String
)
1015 Length
= ACPI_STRLEN (Child
->Asl
.Value
.String
);
1016 Gbl_TableId
= AcpiOsAllocate (Length
+ 1);
1017 ACPI_STRCPY (Gbl_TableId
, Child
->Asl
.Value
.String
);
1019 for (i
= 0; i
< Length
; i
++)
1021 if (Gbl_TableId
[i
] == ' ')
1031 Child
= Child
->Asl
.Next
;
1032 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
1036 /*******************************************************************************
1038 * FUNCTION: UtGetArg
1040 * PARAMETERS: Op - Get an argument for this op
1041 * Argn - Nth argument to get
1043 * RETURN: The argument (as an Op object). NULL if argument does not exist
1045 * DESCRIPTION: Get the specified op's argument (peer)
1047 ******************************************************************************/
1051 ACPI_PARSE_OBJECT
*Op
,
1054 ACPI_PARSE_OBJECT
*Arg
= NULL
;
1057 /* Get the requested argument object */
1059 Arg
= Op
->Asl
.Child
;
1063 Arg
= Arg
->Asl
.Next
;
1070 /*******************************************************************************
1072 * FUNCTION: OpnAttachNameToNode
1074 * PARAMETERS: Op - The parent parse node
1078 * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1079 * argument list and attach it to the parent node so that we
1080 * can get to it quickly later.
1082 ******************************************************************************/
1085 OpnAttachNameToNode (
1086 ACPI_PARSE_OBJECT
*Op
)
1088 ACPI_PARSE_OBJECT
*Child
= NULL
;
1091 if (Op
->Asl
.ParseOpcode
== PARSEOP_EXTERNAL
)
1093 Child
= UtGetArg (Op
, 0);
1095 else switch (Op
->Asl
.AmlOpcode
)
1097 case AML_DATA_REGION_OP
:
1103 case AML_POWER_RES_OP
:
1104 case AML_PROCESSOR_OP
:
1105 case AML_THERMAL_ZONE_OP
:
1109 Child
= UtGetArg (Op
, 0);
1114 Child
= UtGetArg (Op
, 1);
1117 case AML_CREATE_BIT_FIELD_OP
:
1118 case AML_CREATE_BYTE_FIELD_OP
:
1119 case AML_CREATE_WORD_FIELD_OP
:
1120 case AML_CREATE_DWORD_FIELD_OP
:
1121 case AML_CREATE_QWORD_FIELD_OP
:
1123 Child
= UtGetArg (Op
, 2);
1126 case AML_CREATE_FIELD_OP
:
1128 Child
= UtGetArg (Op
, 3);
1131 case AML_BANK_FIELD_OP
:
1132 case AML_INDEX_FIELD_OP
:
1143 UtAttachNamepathToOwner (Op
, Child
);
1148 /*******************************************************************************
1150 * FUNCTION: OpnGenerateAmlOperands
1152 * PARAMETERS: Op - The parent parse node
1156 * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
1157 * complex AML opcodes require processing of the child nodes
1158 * (arguments/operands).
1160 ******************************************************************************/
1163 OpnGenerateAmlOperands (
1164 ACPI_PARSE_OBJECT
*Op
)
1168 if (Op
->Asl
.AmlOpcode
== AML_RAW_DATA_BYTE
)
1173 switch (Op
->Asl
.ParseOpcode
)
1175 case PARSEOP_DEFINITIONBLOCK
:
1176 OpnDoDefinitionBlock (Op
);
1179 case PARSEOP_METHOD
:
1191 case PARSEOP_INDEXFIELD
:
1192 OpnDoIndexField (Op
);
1195 case PARSEOP_BANKFIELD
:
1196 OpnDoBankField (Op
);
1199 case PARSEOP_BUFFER
:
1203 case PARSEOP_LOADTABLE
:
1204 OpnDoLoadTable (Op
);
1207 case PARSEOP_OPERATIONREGION
:
1211 case PARSEOP_RESOURCETEMPLATE
:
1212 RsDoResourceTemplate (Op
);
1215 case PARSEOP_NAMESEG
:
1216 case PARSEOP_NAMESTRING
:
1217 case PARSEOP_METHODCALL
:
1218 case PARSEOP_STRING_LITERAL
:
1227 OpnAttachNameToNode (Op
);