1 /******************************************************************************
3 * Module Name: asloperands - AML operand processing
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include "aslcompiler.h"
46 #include "aslcompiler.y.h"
49 #define _COMPONENT ACPI_COMPILER
50 ACPI_MODULE_NAME ("asloperands")
52 /* Local prototypes */
56 ACPI_PARSE_OBJECT
*Op
);
60 ACPI_PARSE_OBJECT
*Op
);
64 ACPI_PARSE_OBJECT
*Op
);
67 OpnDoDefinitionBlock (
68 ACPI_PARSE_OBJECT
*Op
);
72 ACPI_PARSE_OBJECT
*FieldOp
,
73 ACPI_PARSE_OBJECT
*Op
);
77 ACPI_PARSE_OBJECT
*Op
);
81 ACPI_PARSE_OBJECT
*Op
);
85 ACPI_PARSE_OBJECT
*Op
);
89 ACPI_PARSE_OBJECT
*Op
);
93 ACPI_PARSE_OBJECT
*Op
);
97 ACPI_PARSE_OBJECT
*Op
);
100 /*******************************************************************************
102 * FUNCTION: OpnDoMutex
104 * PARAMETERS: Op - The parent parse node
108 * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
110 ******************************************************************************/
114 ACPI_PARSE_OBJECT
*Op
)
116 ACPI_PARSE_OBJECT
*Next
;
119 Next
= Op
->Asl
.Child
;
120 Next
= Next
->Asl
.Next
;
122 if (Next
->Asl
.Value
.Integer
> 15)
124 AslError (ASL_ERROR
, ASL_MSG_SYNC_LEVEL
, Next
, NULL
);
130 /*******************************************************************************
132 * FUNCTION: OpnDoMethod
134 * PARAMETERS: Op - The parent parse node
138 * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
140 ******************************************************************************/
144 ACPI_PARSE_OBJECT
*Op
)
146 ACPI_PARSE_OBJECT
*Next
;
148 /* Optional arguments for this opcode with defaults */
151 UINT8 Serialized
= 0;
152 UINT8 Concurrency
= 0;
156 /* Opcode and package length first */
159 Next
= Op
->Asl
.Child
;
163 Next
= Next
->Asl
.Next
;
164 if (Next
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
166 NumArgs
= (UINT8
) Next
->Asl
.Value
.Integer
;
167 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
170 /* Serialized Flag */
172 Next
= Next
->Asl
.Next
;
173 if (Next
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
175 Serialized
= (UINT8
) Next
->Asl
.Value
.Integer
;
176 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
179 /* Concurrency value (valid values are 0-15) */
181 Next
= Next
->Asl
.Next
;
182 if (Next
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
184 /* This is a ByteConstExpr, so eval the constant now */
186 OpcAmlConstantWalk (Next
, 0, NULL
);
188 if (Next
->Asl
.Value
.Integer
> 15)
190 AslError (ASL_ERROR
, ASL_MSG_SYNC_LEVEL
, Next
, NULL
);
192 Concurrency
= (UINT8
) Next
->Asl
.Value
.Integer
;
195 /* Put the bits in their proper places */
197 MethodFlags
= (UINT8
) ((NumArgs
& 0x7) |
198 ((Serialized
& 0x1) << 3) |
199 ((Concurrency
& 0xF) << 4));
201 /* Use the last node for the combined flags byte */
203 Next
->Asl
.Value
.Integer
= MethodFlags
;
204 Next
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
205 Next
->Asl
.AmlLength
= 1;
206 Next
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
208 /* Save the arg count in the first node */
210 Op
->Asl
.Extra
= NumArgs
;
214 /*******************************************************************************
216 * FUNCTION: OpnDoFieldCommon
218 * PARAMETERS: FieldOp - Node for an ASL field
219 * Op - The parent parse node
223 * DESCRIPTION: Construct the AML operands for the various field keywords,
224 * FIELD, BANKFIELD, INDEXFIELD
226 ******************************************************************************/
230 ACPI_PARSE_OBJECT
*FieldOp
,
231 ACPI_PARSE_OBJECT
*Op
)
233 ACPI_PARSE_OBJECT
*Next
;
234 ACPI_PARSE_OBJECT
*PkgLengthNode
;
235 UINT32 CurrentBitOffset
;
241 UINT32 MinimumLength
;
244 /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
246 AccessType
= (UINT8
) Op
->Asl
.Value
.Integer
;
247 Op
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
249 /* Set the access type in the parent (field) node for use later */
251 FieldOp
->Asl
.Value
.Integer
= AccessType
;
253 /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
256 LockRule
= (UINT8
) Next
->Asl
.Value
.Integer
;
257 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
259 /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
261 Next
= Next
->Asl
.Next
;
262 UpdateRule
= (UINT8
) Next
->Asl
.Value
.Integer
;
265 * Generate the flags byte. The various fields are already
266 * in the right bit position via translation from the
267 * keywords by the parser.
269 FieldFlags
= (UINT8
) (AccessType
| LockRule
| UpdateRule
);
271 /* Use the previous node to be the FieldFlags node */
273 /* Set the node to RAW_DATA */
275 Next
->Asl
.Value
.Integer
= FieldFlags
;
276 Next
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
277 Next
->Asl
.AmlLength
= 1;
278 Next
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
280 /* Process the FieldUnitList */
282 Next
= Next
->Asl
.Next
;
283 CurrentBitOffset
= 0;
287 /* Save the offset of this field unit */
289 Next
->Asl
.ExtraValue
= CurrentBitOffset
;
291 switch (Next
->Asl
.ParseOpcode
)
293 case PARSEOP_ACCESSAS
:
295 PkgLengthNode
= Next
->Asl
.Child
;
296 AccessType
= (UINT8
) PkgLengthNode
->Asl
.Value
.Integer
;
298 /* Nothing additional to do */
303 /* New offset into the field */
305 PkgLengthNode
= Next
->Asl
.Child
;
306 NewBitOffset
= ((UINT32
) PkgLengthNode
->Asl
.Value
.Integer
) * 8;
309 * Examine the specified offset in relation to the
310 * current offset counter.
312 if (NewBitOffset
< CurrentBitOffset
)
315 * Not allowed to specify a backwards offset!
316 * Issue error and ignore this node.
318 AslError (ASL_ERROR
, ASL_MSG_BACKWARDS_OFFSET
, PkgLengthNode
,
320 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
321 PkgLengthNode
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
323 else if (NewBitOffset
== CurrentBitOffset
)
326 * Offset is redundant; we don't need to output an
327 * offset opcode. Just set these nodes to default
329 Next
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
330 PkgLengthNode
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
335 * Valid new offset - set the value to be inserted into the AML
336 * and update the offset counter.
338 PkgLengthNode
->Asl
.Value
.Integer
=
339 NewBitOffset
- CurrentBitOffset
;
340 CurrentBitOffset
= NewBitOffset
;
344 case PARSEOP_NAMESEG
:
345 case PARSEOP_RESERVED_BYTES
:
347 /* Named or reserved field entry */
349 PkgLengthNode
= Next
->Asl
.Child
;
350 NewBitOffset
= (UINT32
) PkgLengthNode
->Asl
.Value
.Integer
;
351 CurrentBitOffset
+= NewBitOffset
;
353 /* Save the current AccessAs value for error checking later */
357 case AML_FIELD_ACCESS_ANY
:
358 case AML_FIELD_ACCESS_BYTE
:
359 case AML_FIELD_ACCESS_BUFFER
:
365 case AML_FIELD_ACCESS_WORD
:
369 case AML_FIELD_ACCESS_DWORD
:
373 case AML_FIELD_ACCESS_QWORD
:
378 PkgLengthNode
->Asl
.ExtraValue
= MinimumLength
;
383 /* All supported field opcodes must appear above */
388 /* Move on to next entry in the field list */
390 Next
= Next
->Asl
.Next
;
395 /*******************************************************************************
397 * FUNCTION: OpnDoField
399 * PARAMETERS: Op - The parent parse node
403 * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
405 ******************************************************************************/
409 ACPI_PARSE_OBJECT
*Op
)
411 ACPI_PARSE_OBJECT
*Next
;
414 /* Opcode is parent node */
415 /* First child is field name */
417 Next
= Op
->Asl
.Child
;
419 /* Second child is the AccessType */
421 OpnDoFieldCommon (Op
, Next
->Asl
.Next
);
425 /*******************************************************************************
427 * FUNCTION: OpnDoIndexField
429 * PARAMETERS: Op - The parent parse node
433 * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
435 ******************************************************************************/
439 ACPI_PARSE_OBJECT
*Op
)
441 ACPI_PARSE_OBJECT
*Next
;
444 /* Opcode is parent node */
445 /* First child is the index name */
447 Next
= Op
->Asl
.Child
;
449 /* Second child is the data name */
451 Next
= Next
->Asl
.Next
;
453 /* Third child is the AccessType */
455 OpnDoFieldCommon (Op
, Next
->Asl
.Next
);
459 /*******************************************************************************
461 * FUNCTION: OpnDoBankField
463 * PARAMETERS: Op - The parent parse node
467 * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
469 ******************************************************************************/
473 ACPI_PARSE_OBJECT
*Op
)
475 ACPI_PARSE_OBJECT
*Next
;
478 /* Opcode is parent node */
479 /* First child is the region name */
481 Next
= Op
->Asl
.Child
;
483 /* Second child is the bank name */
485 Next
= Next
->Asl
.Next
;
487 /* Third child is the bank value */
489 Next
= Next
->Asl
.Next
;
491 /* Fourth child is the AccessType */
493 OpnDoFieldCommon (Op
, Next
->Asl
.Next
);
497 /*******************************************************************************
499 * FUNCTION: OpnDoRegion
501 * PARAMETERS: Op - The parent parse node
505 * DESCRIPTION: Tries to get the length of the region. Can only do this at
506 * compile time if the length is a constant.
508 ******************************************************************************/
512 ACPI_PARSE_OBJECT
*Op
)
514 ACPI_PARSE_OBJECT
*Next
;
517 /* Opcode is parent node */
518 /* First child is the region name */
520 Next
= Op
->Asl
.Child
;
522 /* Second child is the space ID*/
524 Next
= Next
->Asl
.Next
;
526 /* Third child is the region offset */
528 Next
= Next
->Asl
.Next
;
530 /* Fourth child is the region length */
532 Next
= Next
->Asl
.Next
;
533 if (Next
->Asl
.ParseOpcode
== PARSEOP_INTEGER
)
535 Op
->Asl
.Value
.Integer
= Next
->Asl
.Value
.Integer
;
539 Op
->Asl
.Value
.Integer
= ACPI_UINT64_MAX
;
544 /*******************************************************************************
546 * FUNCTION: OpnDoBuffer
548 * PARAMETERS: Op - The parent parse node
552 * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
553 * build a single raw byte buffer from the initialization nodes,
554 * each parse node contains a buffer byte.
556 ******************************************************************************/
560 ACPI_PARSE_OBJECT
*Op
)
562 ACPI_PARSE_OBJECT
*InitializerOp
;
563 ACPI_PARSE_OBJECT
*BufferLengthOp
;
565 /* Optional arguments for this opcode with defaults */
567 UINT32 BufferLength
= 0;
570 /* Opcode and package length first */
571 /* Buffer Length is next, followed by the initializer list */
573 BufferLengthOp
= Op
->Asl
.Child
;
574 InitializerOp
= BufferLengthOp
->Asl
.Next
;
577 * If the BufferLength is not an INTEGER or was not specified in the ASL
578 * (DEFAULT_ARG), it is a TermArg that is
579 * evaluated at run-time, and we are therefore finished.
581 if ((BufferLengthOp
->Asl
.ParseOpcode
!= PARSEOP_INTEGER
) &&
582 (BufferLengthOp
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
))
588 * We want to count the number of items in the initializer list, because if
589 * it is larger than the buffer length, we will define the buffer size
590 * to be the size of the initializer list (as per the ACPI Specification)
592 switch (InitializerOp
->Asl
.ParseOpcode
)
594 case PARSEOP_INTEGER
:
595 case PARSEOP_BYTECONST
:
596 case PARSEOP_WORDCONST
:
597 case PARSEOP_DWORDCONST
:
599 /* The peer list contains the byte list (if any...) */
601 while (InitializerOp
)
603 /* For buffers, this is a list of raw bytes */
605 InitializerOp
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
606 InitializerOp
->Asl
.AmlLength
= 1;
607 InitializerOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
610 InitializerOp
= ASL_GET_PEER_NODE (InitializerOp
);
614 case PARSEOP_STRING_LITERAL
:
617 * Only one initializer, the string. Buffer must be big enough to hold
618 * the string plus the null termination byte
620 BufferLength
= strlen (InitializerOp
->Asl
.Value
.String
) + 1;
622 InitializerOp
->Asl
.AmlOpcode
= AML_RAW_DATA_BUFFER
;
623 InitializerOp
->Asl
.AmlLength
= BufferLength
;
624 InitializerOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
627 case PARSEOP_RAW_DATA
:
629 /* Buffer nodes are already initialized (e.g. Unicode operator) */
632 case PARSEOP_DEFAULT_ARG
:
637 AslError (ASL_ERROR
, ASL_MSG_INVALID_OPERAND
, InitializerOp
,
638 "Unknown buffer initializer opcode");
639 printf ("Unknown buffer initializer opcode [%s]\n",
640 UtGetOpName (InitializerOp
->Asl
.ParseOpcode
));
644 /* Check if initializer list is longer than the buffer length */
646 if (BufferLengthOp
->Asl
.Value
.Integer
> BufferLength
)
648 BufferLength
= (UINT32
) BufferLengthOp
->Asl
.Value
.Integer
;
653 /* No length AND no items -- issue notice */
655 AslError (ASL_REMARK
, ASL_MSG_BUFFER_LENGTH
, BufferLengthOp
, NULL
);
657 /* But go ahead and put the buffer length of zero into the AML */
661 * Just set the buffer size node to be the buffer length, regardless
662 * of whether it was previously an integer or a default_arg placeholder
664 BufferLengthOp
->Asl
.ParseOpcode
= PARSEOP_INTEGER
;
665 BufferLengthOp
->Asl
.AmlOpcode
= AML_DWORD_OP
;
666 BufferLengthOp
->Asl
.Value
.Integer
= BufferLength
;
668 (void) OpcSetOptimalIntegerSize (BufferLengthOp
);
670 /* Remaining nodes are handled via the tree walk */
674 /*******************************************************************************
676 * FUNCTION: OpnDoPackage
678 * PARAMETERS: Op - The parent parse node
682 * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
683 * can only be called after constants have been folded, to ensure
684 * that the PackageLength operand has been fully reduced.
686 ******************************************************************************/
690 ACPI_PARSE_OBJECT
*Op
)
692 ACPI_PARSE_OBJECT
*InitializerOp
;
693 ACPI_PARSE_OBJECT
*PackageLengthOp
;
694 UINT32 PackageLength
= 0;
697 /* Opcode and package length first, followed by the initializer list */
699 PackageLengthOp
= Op
->Asl
.Child
;
700 InitializerOp
= PackageLengthOp
->Asl
.Next
;
702 /* Count the number of items in the initializer list */
704 if (InitializerOp
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
706 /* The peer list contains the byte list (if any...) */
708 while (InitializerOp
)
711 InitializerOp
= InitializerOp
->Asl
.Next
;
715 /* If package length is a constant, compare to the initializer list */
717 if ((PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) ||
718 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_QWORDCONST
))
720 if (PackageLengthOp
->Asl
.Value
.Integer
> PackageLength
)
723 * Allow package length to be longer than the initializer
724 * list -- but if the length of initializer list is nonzero,
725 * issue a message since this is probably a coding error,
726 * even though technically legal.
728 if (PackageLength
> 0)
730 AslError (ASL_REMARK
, ASL_MSG_LIST_LENGTH_SHORT
,
731 PackageLengthOp
, NULL
);
734 PackageLength
= (UINT32
) PackageLengthOp
->Asl
.Value
.Integer
;
736 else if (PackageLengthOp
->Asl
.Value
.Integer
< PackageLength
)
739 * The package length is smaller than the length of the
740 * initializer list. This is an error as per the ACPI spec.
742 AslError (ASL_ERROR
, ASL_MSG_LIST_LENGTH_LONG
,
743 PackageLengthOp
, NULL
);
747 if (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
)
750 * This is the case if the PackageLength was left empty - Package()
751 * The package length becomes the length of the initializer list
753 Op
->Asl
.Child
->Asl
.ParseOpcode
= PARSEOP_INTEGER
;
754 Op
->Asl
.Child
->Asl
.Value
.Integer
= PackageLength
;
756 /* Set the AML opcode */
758 (void) OpcSetOptimalIntegerSize (Op
->Asl
.Child
);
761 /* If not a variable-length package, check for a zero package length */
763 if ((PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) ||
764 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_QWORDCONST
) ||
765 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_ZERO
) ||
766 (PackageLengthOp
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
))
770 /* No length AND no initializer list -- issue a remark */
772 AslError (ASL_REMARK
, ASL_MSG_PACKAGE_LENGTH
,
773 PackageLengthOp
, NULL
);
775 /* But go ahead and put the buffer length of zero into the AML */
780 * If the PackageLength is a constant <= 255, we can change the
781 * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
783 if (((Op
->Asl
.Child
->Asl
.ParseOpcode
== PARSEOP_INTEGER
) &&
784 (Op
->Asl
.Child
->Asl
.Value
.Integer
<= 255)) ||
785 (Op
->Asl
.Child
->Asl
.ParseOpcode
== PARSEOP_ONE
) ||
786 (Op
->Asl
.Child
->Asl
.ParseOpcode
== PARSEOP_ONES
)||
787 (Op
->Asl
.Child
->Asl
.ParseOpcode
== PARSEOP_ZERO
))
789 Op
->Asl
.AmlOpcode
= AML_PACKAGE_OP
;
790 Op
->Asl
.ParseOpcode
= PARSEOP_PACKAGE
;
793 * Just set the package size node to be the package length, regardless
794 * of whether it was previously an integer or a default_arg placeholder
796 PackageLengthOp
->Asl
.AmlOpcode
= AML_RAW_DATA_BYTE
;
797 PackageLengthOp
->Asl
.AmlLength
= 1;
798 PackageLengthOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
799 PackageLengthOp
->Asl
.Value
.Integer
= PackageLength
;
802 /* Remaining nodes are handled via the tree walk */
806 /*******************************************************************************
808 * FUNCTION: OpnDoLoadTable
810 * PARAMETERS: Op - The parent parse node
814 * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
816 ******************************************************************************/
820 ACPI_PARSE_OBJECT
*Op
)
822 ACPI_PARSE_OBJECT
*Next
;
825 /* Opcode is parent node */
826 /* First child is the table signature */
828 Next
= Op
->Asl
.Child
;
830 /* Second child is the OEM ID*/
832 Next
= Next
->Asl
.Next
;
834 /* Third child is the OEM table ID */
836 Next
= Next
->Asl
.Next
;
838 /* Fourth child is the RootPath string */
840 Next
= Next
->Asl
.Next
;
841 if (Next
->Asl
.ParseOpcode
== PARSEOP_ZERO
)
843 Next
->Asl
.ParseOpcode
= PARSEOP_STRING_LITERAL
;
844 Next
->Asl
.Value
.String
= "\\";
845 Next
->Asl
.AmlLength
= 2;
846 OpcGenerateAmlOpcode (Next
);
849 #ifdef ASL_FUTURE_IMPLEMENTATION
851 /* TBD: NOT IMPLEMENTED */
852 /* Fifth child is the [optional] ParameterPathString */
853 /* Sixth child is the [optional] ParameterData */
855 Next
= Next
->Asl
.Next
;
856 if (Next
->Asl
.ParseOpcode
== DEFAULT_ARG
)
858 Next
->Asl
.AmlLength
= 1;
859 Next
->Asl
.ParseOpcode
= ZERO
;
860 OpcGenerateAmlOpcode (Next
);
864 Next
= Next
->Asl
.Next
;
865 if (Next
->Asl
.ParseOpcode
== DEFAULT_ARG
)
867 Next
->Asl
.AmlLength
= 1;
868 Next
->Asl
.ParseOpcode
= ZERO
;
869 OpcGenerateAmlOpcode (Next
);
875 /*******************************************************************************
877 * FUNCTION: OpnDoDefinitionBlock
879 * PARAMETERS: Op - The parent parse node
883 * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
885 ******************************************************************************/
888 OpnDoDefinitionBlock (
889 ACPI_PARSE_OBJECT
*Op
)
891 ACPI_PARSE_OBJECT
*Child
;
898 * These nodes get stuffed into the table header. They are special
899 * cased when the table is written to the output file.
901 * Mark all of these nodes as non-usable so they won't get output
905 /* Get AML filename. Use it if non-null */
907 Child
= Op
->Asl
.Child
;
908 if (Child
->Asl
.Value
.Buffer
&&
909 *Child
->Asl
.Value
.Buffer
&&
910 (Gbl_UseDefaultAmlFilename
))
913 * We will use the AML filename that is embedded in the source file
914 * for the output filename.
916 Filename
= ACPI_ALLOCATE (strlen (Gbl_DirectoryPath
) +
917 strlen ((char *) Child
->Asl
.Value
.Buffer
) + 1);
919 /* Prepend the current directory path */
921 strcpy (Filename
, Gbl_DirectoryPath
);
922 strcat (Filename
, (char *) Child
->Asl
.Value
.Buffer
);
924 Gbl_OutputFilenamePrefix
= Filename
;
926 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
930 Child
= Child
->Asl
.Next
;
931 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
932 if (Child
->Asl
.Value
.String
)
934 Gbl_TableSignature
= Child
->Asl
.Value
.String
;
935 if (ACPI_STRLEN (Gbl_TableSignature
) != 4)
937 AslError (ASL_ERROR
, ASL_MSG_TABLE_SIGNATURE
, Child
,
938 "Length not exactly 4");
941 for (i
= 0; i
< 4; i
++)
943 if (!isalnum ((int) Gbl_TableSignature
[i
]))
945 AslError (ASL_ERROR
, ASL_MSG_TABLE_SIGNATURE
, Child
,
946 "Contains non-alphanumeric characters");
953 Child
= Child
->Asl
.Next
;
954 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
956 * We used the revision to set the integer width earlier
961 Child
= Child
->Asl
.Next
;
962 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
966 Child
= Child
->Asl
.Next
;
967 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
968 if (Child
->Asl
.Value
.String
)
970 Length
= ACPI_STRLEN (Child
->Asl
.Value
.String
);
971 Gbl_TableId
= AcpiOsAllocate (Length
+ 1);
972 ACPI_STRCPY (Gbl_TableId
, Child
->Asl
.Value
.String
);
975 * Convert anything non-alphanumeric to an underscore. This
976 * allows us to use the TableID to generate unique C symbols.
978 for (i
= 0; i
< Length
; i
++)
980 if (!isalnum ((int) Gbl_TableId
[i
]))
982 Gbl_TableId
[i
] = '_';
989 Child
= Child
->Asl
.Next
;
990 Child
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
994 /*******************************************************************************
998 * PARAMETERS: Op - Get an argument for this op
999 * Argn - Nth argument to get
1001 * RETURN: The argument (as an Op object). NULL if argument does not exist
1003 * DESCRIPTION: Get the specified op's argument (peer)
1005 ******************************************************************************/
1009 ACPI_PARSE_OBJECT
*Op
,
1012 ACPI_PARSE_OBJECT
*Arg
= NULL
;
1015 /* Get the requested argument object */
1017 Arg
= Op
->Asl
.Child
;
1021 Arg
= Arg
->Asl
.Next
;
1028 /*******************************************************************************
1030 * FUNCTION: OpnAttachNameToNode
1032 * PARAMETERS: Op - The parent parse node
1036 * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1037 * argument list and attach it to the parent node so that we
1038 * can get to it quickly later.
1040 ******************************************************************************/
1043 OpnAttachNameToNode (
1044 ACPI_PARSE_OBJECT
*Op
)
1046 ACPI_PARSE_OBJECT
*Child
= NULL
;
1049 if (Op
->Asl
.ParseOpcode
== PARSEOP_EXTERNAL
)
1051 Child
= UtGetArg (Op
, 0);
1053 else switch (Op
->Asl
.AmlOpcode
)
1055 case AML_DATA_REGION_OP
:
1061 case AML_POWER_RES_OP
:
1062 case AML_PROCESSOR_OP
:
1063 case AML_THERMAL_ZONE_OP
:
1067 Child
= UtGetArg (Op
, 0);
1072 Child
= UtGetArg (Op
, 1);
1075 case AML_CREATE_BIT_FIELD_OP
:
1076 case AML_CREATE_BYTE_FIELD_OP
:
1077 case AML_CREATE_WORD_FIELD_OP
:
1078 case AML_CREATE_DWORD_FIELD_OP
:
1079 case AML_CREATE_QWORD_FIELD_OP
:
1081 Child
= UtGetArg (Op
, 2);
1084 case AML_CREATE_FIELD_OP
:
1086 Child
= UtGetArg (Op
, 3);
1089 case AML_BANK_FIELD_OP
:
1090 case AML_INDEX_FIELD_OP
:
1102 UtAttachNamepathToOwner (Op
, Child
);
1107 /*******************************************************************************
1109 * FUNCTION: OpnGenerateAmlOperands
1111 * PARAMETERS: Op - The parent parse node
1115 * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
1116 * complex AML opcodes require processing of the child nodes
1117 * (arguments/operands).
1119 ******************************************************************************/
1122 OpnGenerateAmlOperands (
1123 ACPI_PARSE_OBJECT
*Op
)
1127 if (Op
->Asl
.AmlOpcode
== AML_RAW_DATA_BYTE
)
1132 switch (Op
->Asl
.ParseOpcode
)
1134 case PARSEOP_DEFINITIONBLOCK
:
1136 OpnDoDefinitionBlock (Op
);
1139 case PARSEOP_METHOD
:
1154 case PARSEOP_INDEXFIELD
:
1156 OpnDoIndexField (Op
);
1159 case PARSEOP_BANKFIELD
:
1161 OpnDoBankField (Op
);
1164 case PARSEOP_BUFFER
:
1169 case PARSEOP_LOADTABLE
:
1171 OpnDoLoadTable (Op
);
1174 case PARSEOP_OPERATIONREGION
:
1179 case PARSEOP_RESOURCETEMPLATE
:
1181 RsDoResourceTemplate (Op
);
1184 case PARSEOP_NAMESEG
:
1185 case PARSEOP_NAMESTRING
:
1186 case PARSEOP_METHODCALL
:
1187 case PARSEOP_STRING_LITERAL
:
1198 OpnAttachNameToNode (Op
);