1 /******************************************************************************
3 * Module Name: asloperands - AML operand processing
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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.
44 #include <contrib/dev/acpica/compiler/aslcompiler.h>
45 #include "aslcompiler.y.h"
46 #include <contrib/dev/acpica/include/amlcode.h>
48 #define _COMPONENT ACPI_COMPILER
49 ACPI_MODULE_NAME ("asloperands")
51 /* Local prototypes */
55 ACPI_PARSE_OBJECT *Op);
59 ACPI_PARSE_OBJECT *Op);
63 ACPI_PARSE_OBJECT *Op);
66 OpnDoDefinitionBlock (
67 ACPI_PARSE_OBJECT *Op);
71 ACPI_PARSE_OBJECT *FieldOp,
72 ACPI_PARSE_OBJECT *Op);
76 ACPI_PARSE_OBJECT *Op);
80 ACPI_PARSE_OBJECT *Op);
84 ACPI_PARSE_OBJECT *Op);
88 ACPI_PARSE_OBJECT *Op);
92 ACPI_PARSE_OBJECT *Op);
96 ACPI_PARSE_OBJECT *Op);
99 /*******************************************************************************
101 * FUNCTION: OpnDoMutex
103 * PARAMETERS: Op - The parent parse node
107 * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
109 ******************************************************************************/
113 ACPI_PARSE_OBJECT *Op)
115 ACPI_PARSE_OBJECT *Next;
118 Next = Op->Asl.Child;
119 Next = Next->Asl.Next;
121 if (Next->Asl.Value.Integer > 15)
123 AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
129 /*******************************************************************************
131 * FUNCTION: OpnDoMethod
133 * PARAMETERS: Op - The parent parse node
137 * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
139 ******************************************************************************/
143 ACPI_PARSE_OBJECT *Op)
145 ACPI_PARSE_OBJECT *Next;
147 /* Optional arguments for this opcode with defaults */
150 UINT8 Serialized = 0;
151 UINT8 Concurrency = 0;
155 /* Opcode and package length first */
158 Next = Op->Asl.Child;
162 Next = Next->Asl.Next;
163 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
165 NumArgs = (UINT8) Next->Asl.Value.Integer;
166 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
169 /* Serialized Flag */
171 Next = Next->Asl.Next;
172 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
174 Serialized = (UINT8) Next->Asl.Value.Integer;
175 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
178 /* Concurrency value (valid values are 0-15) */
180 Next = Next->Asl.Next;
181 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
183 /* This is a ByteConstExpr, so eval the constant now */
185 OpcAmlConstantWalk (Next, 0, NULL);
187 if (Next->Asl.Value.Integer > 15)
189 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)
199 ((Serialized & 0x1) << 3) |
200 ((Concurrency & 0xF) << 4));
202 /* Use the last node for the combined flags byte */
204 Next->Asl.Value.Integer = MethodFlags;
205 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
206 Next->Asl.AmlLength = 1;
207 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
209 /* Save the arg count in the first node */
211 Op->Asl.Extra = NumArgs;
215 /*******************************************************************************
217 * FUNCTION: OpnDoFieldCommon
219 * PARAMETERS: FieldOp - Node for an ASL field
220 * Op - The parent parse node
224 * DESCRIPTION: Construct the AML operands for the various field keywords,
225 * FIELD, BANKFIELD, INDEXFIELD
227 ******************************************************************************/
231 ACPI_PARSE_OBJECT *FieldOp,
232 ACPI_PARSE_OBJECT *Op)
234 ACPI_PARSE_OBJECT *Next;
235 ACPI_PARSE_OBJECT *PkgLengthNode;
236 UINT32 CurrentBitOffset;
242 UINT32 MinimumLength;
245 /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
247 AccessType = (UINT8) Op->Asl.Value.Integer;
248 Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
250 /* Set the access type in the parent (field) node for use later */
252 FieldOp->Asl.Value.Integer = AccessType;
254 /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
257 LockRule = (UINT8) Next->Asl.Value.Integer;
258 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
260 /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
262 Next = Next->Asl.Next;
263 UpdateRule = (UINT8) Next->Asl.Value.Integer;
266 * Generate the flags byte. The various fields are already
267 * in the right bit position via translation from the
268 * keywords by the parser.
270 FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule);
272 /* Use the previous node to be the FieldFlags node */
274 /* Set the node to RAW_DATA */
276 Next->Asl.Value.Integer = FieldFlags;
277 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
278 Next->Asl.AmlLength = 1;
279 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
281 /* Process the FieldUnitList */
283 Next = Next->Asl.Next;
284 CurrentBitOffset = 0;
288 /* Save the offset of this field unit */
290 Next->Asl.ExtraValue = CurrentBitOffset;
292 switch (Next->Asl.ParseOpcode)
294 case PARSEOP_ACCESSAS:
296 PkgLengthNode = Next->Asl.Child;
297 AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer;
299 /* Nothing additional to do */
304 /* New offset into the field */
306 PkgLengthNode = Next->Asl.Child;
307 NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8;
310 * Examine the specified offset in relation to the
311 * current offset counter.
313 if (NewBitOffset < CurrentBitOffset)
316 * Not allowed to specify a backwards offset!
317 * Issue error and ignore this node.
319 AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode,
321 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
322 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
324 else if (NewBitOffset == CurrentBitOffset)
327 * Offset is redundant; we don't need to output an
328 * offset opcode. Just set these nodes to default
330 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
331 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
336 * Valid new offset - set the value to be inserted into the AML
337 * and update the offset counter.
339 PkgLengthNode->Asl.Value.Integer =
340 NewBitOffset - CurrentBitOffset;
341 CurrentBitOffset = NewBitOffset;
345 case PARSEOP_NAMESEG:
346 case PARSEOP_RESERVED_BYTES:
348 /* Named or reserved field entry */
350 PkgLengthNode = Next->Asl.Child;
351 NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer;
352 CurrentBitOffset += NewBitOffset;
354 /* Save the current AccessAs value for error checking later */
358 case AML_FIELD_ACCESS_ANY:
359 case AML_FIELD_ACCESS_BYTE:
360 case AML_FIELD_ACCESS_BUFFER:
366 case AML_FIELD_ACCESS_WORD:
370 case AML_FIELD_ACCESS_DWORD:
374 case AML_FIELD_ACCESS_QWORD:
379 PkgLengthNode->Asl.ExtraValue = MinimumLength;
384 /* All supported field opcodes must appear above */
389 /* Move on to next entry in the field list */
391 Next = Next->Asl.Next;
396 /*******************************************************************************
398 * FUNCTION: OpnDoField
400 * PARAMETERS: Op - The parent parse node
404 * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
406 ******************************************************************************/
410 ACPI_PARSE_OBJECT *Op)
412 ACPI_PARSE_OBJECT *Next;
415 /* Opcode is parent node */
416 /* First child is field name */
418 Next = Op->Asl.Child;
420 /* Second child is the AccessType */
422 OpnDoFieldCommon (Op, Next->Asl.Next);
426 /*******************************************************************************
428 * FUNCTION: OpnDoIndexField
430 * PARAMETERS: Op - The parent parse node
434 * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
436 ******************************************************************************/
440 ACPI_PARSE_OBJECT *Op)
442 ACPI_PARSE_OBJECT *Next;
445 /* Opcode is parent node */
446 /* First child is the index name */
448 Next = Op->Asl.Child;
450 /* Second child is the data name */
452 Next = Next->Asl.Next;
454 /* Third child is the AccessType */
456 OpnDoFieldCommon (Op, Next->Asl.Next);
460 /*******************************************************************************
462 * FUNCTION: OpnDoBankField
464 * PARAMETERS: Op - The parent parse node
468 * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
470 ******************************************************************************/
474 ACPI_PARSE_OBJECT *Op)
476 ACPI_PARSE_OBJECT *Next;
479 /* Opcode is parent node */
480 /* First child is the region name */
482 Next = Op->Asl.Child;
484 /* Second child is the bank name */
486 Next = Next->Asl.Next;
488 /* Third child is the bank value */
490 Next = Next->Asl.Next;
492 /* Fourth child is the AccessType */
494 OpnDoFieldCommon (Op, Next->Asl.Next);
498 /*******************************************************************************
500 * FUNCTION: OpnDoRegion
502 * PARAMETERS: Op - The parent parse node
506 * DESCRIPTION: Tries to get the length of the region. Can only do this at
507 * compile time if the length is a constant.
509 ******************************************************************************/
513 ACPI_PARSE_OBJECT *Op)
515 ACPI_PARSE_OBJECT *Next;
518 /* Opcode is parent node */
519 /* First child is the region name */
521 Next = Op->Asl.Child;
523 /* Second child is the space ID*/
525 Next = Next->Asl.Next;
527 /* Third child is the region offset */
529 Next = Next->Asl.Next;
531 /* Fourth child is the region length */
533 Next = Next->Asl.Next;
534 if (Next->Asl.ParseOpcode == PARSEOP_INTEGER)
536 Op->Asl.Value.Integer = Next->Asl.Value.Integer;
540 Op->Asl.Value.Integer = ACPI_UINT64_MAX;
545 /*******************************************************************************
547 * FUNCTION: OpnDoBuffer
549 * PARAMETERS: Op - The parent parse node
553 * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
554 * build a single raw byte buffer from the initialization nodes,
555 * each parse node contains a buffer byte.
557 ******************************************************************************/
561 ACPI_PARSE_OBJECT *Op)
563 ACPI_PARSE_OBJECT *InitializerOp;
564 ACPI_PARSE_OBJECT *BufferLengthOp;
566 /* Optional arguments for this opcode with defaults */
568 UINT32 BufferLength = 0;
571 /* Opcode and package length first */
572 /* Buffer Length is next, followed by the initializer list */
574 BufferLengthOp = Op->Asl.Child;
575 InitializerOp = BufferLengthOp->Asl.Next;
578 * If the BufferLength is not an INTEGER or was not specified in the ASL
579 * (DEFAULT_ARG), it is a TermArg that is
580 * evaluated at run-time, and we are therefore finished.
582 if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
583 (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
589 * We want to count the number of items in the initializer list, because if
590 * it is larger than the buffer length, we will define the buffer size
591 * to be the size of the initializer list (as per the ACPI Specification)
593 switch (InitializerOp->Asl.ParseOpcode)
595 case PARSEOP_INTEGER:
596 case PARSEOP_BYTECONST:
597 case PARSEOP_WORDCONST:
598 case PARSEOP_DWORDCONST:
600 /* The peer list contains the byte list (if any...) */
602 while (InitializerOp)
604 /* For buffers, this is a list of raw bytes */
606 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
607 InitializerOp->Asl.AmlLength = 1;
608 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
611 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
615 case PARSEOP_STRING_LITERAL:
618 * Only one initializer, the string. Buffer must be big enough to hold
619 * the string plus the null termination byte
621 BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
623 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
624 InitializerOp->Asl.AmlLength = BufferLength;
625 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
628 case PARSEOP_RAW_DATA:
630 /* Buffer nodes are already initialized (e.g. Unicode operator) */
633 case PARSEOP_DEFAULT_ARG:
638 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
639 "Unknown buffer initializer opcode");
640 printf ("Unknown buffer initializer opcode [%s]\n",
641 UtGetOpName (InitializerOp->Asl.ParseOpcode));
645 /* Check if initializer list is longer than the buffer length */
647 if (BufferLengthOp->Asl.Value.Integer > BufferLength)
649 BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
654 /* No length AND no items -- issue notice */
656 AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
658 /* But go ahead and put the buffer length of zero into the AML */
662 * Just set the buffer size node to be the buffer length, regardless
663 * of whether it was previously an integer or a default_arg placeholder
665 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
666 BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
667 BufferLengthOp->Asl.Value.Integer = BufferLength;
669 (void) OpcSetOptimalIntegerSize (BufferLengthOp);
671 /* Remaining nodes are handled via the tree walk */
675 /*******************************************************************************
677 * FUNCTION: OpnDoPackage
679 * PARAMETERS: Op - The parent parse node
683 * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
684 * can only be called after constants have been folded, to ensure
685 * that the PackageLength operand has been fully reduced.
687 ******************************************************************************/
691 ACPI_PARSE_OBJECT *Op)
693 ACPI_PARSE_OBJECT *InitializerOp;
694 ACPI_PARSE_OBJECT *PackageLengthOp;
695 UINT32 PackageLength = 0;
698 /* Opcode and package length first, followed by the initializer list */
700 PackageLengthOp = Op->Asl.Child;
701 InitializerOp = PackageLengthOp->Asl.Next;
703 /* Count the number of items in the initializer list */
705 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
707 /* The peer list contains the byte list (if any...) */
709 while (InitializerOp)
712 InitializerOp = InitializerOp->Asl.Next;
716 /* If package length is a constant, compare to the initializer list */
718 if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
719 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST))
721 if (PackageLengthOp->Asl.Value.Integer > PackageLength)
724 * Allow package length to be longer than the initializer
725 * list -- but if the length of initializer list is nonzero,
726 * issue a message since this is probably a coding error,
727 * even though technically legal.
729 if (PackageLength > 0)
731 AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT,
732 PackageLengthOp, NULL);
735 PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer;
737 else if (PackageLengthOp->Asl.Value.Integer < PackageLength)
740 * The package length is smaller than the length of the
741 * initializer list. This is an error as per the ACPI spec.
743 AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG,
744 PackageLengthOp, NULL);
748 if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
751 * This is the case if the PackageLength was left empty - Package()
752 * The package length becomes the length of the initializer list
754 Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
755 Op->Asl.Child->Asl.Value.Integer = PackageLength;
757 /* Set the AML opcode */
759 (void) OpcSetOptimalIntegerSize (Op->Asl.Child);
762 /* If not a variable-length package, check for a zero package length */
764 if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
765 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) ||
766 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_ZERO) ||
767 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
771 /* No length AND no initializer list -- issue a remark */
773 AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH,
774 PackageLengthOp, NULL);
776 /* But go ahead and put the buffer length of zero into the AML */
781 * If the PackageLength is a constant <= 255, we can change the
782 * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
784 if (((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
785 (Op->Asl.Child->Asl.Value.Integer <= 255)) ||
786 (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONE) ||
787 (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONES)||
788 (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ZERO))
790 Op->Asl.AmlOpcode = AML_PACKAGE_OP;
791 Op->Asl.ParseOpcode = PARSEOP_PACKAGE;
794 * Just set the package size node to be the package length, regardless
795 * of whether it was previously an integer or a default_arg placeholder
797 PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
798 PackageLengthOp->Asl.AmlLength = 1;
799 PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
800 PackageLengthOp->Asl.Value.Integer = PackageLength;
803 /* Remaining nodes are handled via the tree walk */
807 /*******************************************************************************
809 * FUNCTION: OpnDoLoadTable
811 * PARAMETERS: Op - The parent parse node
815 * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
817 ******************************************************************************/
821 ACPI_PARSE_OBJECT *Op)
823 ACPI_PARSE_OBJECT *Next;
826 /* Opcode is parent node */
827 /* First child is the table signature */
829 Next = Op->Asl.Child;
831 /* Second child is the OEM ID*/
833 Next = Next->Asl.Next;
835 /* Third child is the OEM table ID */
837 Next = Next->Asl.Next;
839 /* Fourth child is the RootPath string */
841 Next = Next->Asl.Next;
842 if (Next->Asl.ParseOpcode == PARSEOP_ZERO)
844 Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
845 Next->Asl.Value.String = "\\";
846 Next->Asl.AmlLength = 2;
847 OpcGenerateAmlOpcode (Next);
850 #ifdef ASL_FUTURE_IMPLEMENTATION
852 /* TBD: NOT IMPLEMENTED */
853 /* Fifth child is the [optional] ParameterPathString */
854 /* Sixth child is the [optional] ParameterData */
856 Next = Next->Asl.Next;
857 if (Next->Asl.ParseOpcode == DEFAULT_ARG)
859 Next->Asl.AmlLength = 1;
860 Next->Asl.ParseOpcode = ZERO;
861 OpcGenerateAmlOpcode (Next);
865 Next = Next->Asl.Next;
866 if (Next->Asl.ParseOpcode == DEFAULT_ARG)
868 Next->Asl.AmlLength = 1;
869 Next->Asl.ParseOpcode = ZERO;
870 OpcGenerateAmlOpcode (Next);
876 /*******************************************************************************
878 * FUNCTION: OpnDoDefinitionBlock
880 * PARAMETERS: Op - The parent parse node
884 * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
886 ******************************************************************************/
889 OpnDoDefinitionBlock (
890 ACPI_PARSE_OBJECT *Op)
892 ACPI_PARSE_OBJECT *Child;
899 * These nodes get stuffed into the table header. They are special
900 * cased when the table is written to the output file.
902 * Mark all of these nodes as non-usable so they won't get output
906 /* Get AML filename. Use it if non-null */
908 Child = Op->Asl.Child;
909 if (Child->Asl.Value.Buffer &&
910 *Child->Asl.Value.Buffer &&
911 (Gbl_UseDefaultAmlFilename))
914 * We will use the AML filename that is embedded in the source file
915 * for the output filename.
917 Filename = UtStringCacheCalloc (strlen (Gbl_DirectoryPath) +
918 strlen ((char *) Child->Asl.Value.Buffer) + 1);
920 /* Prepend the current directory path */
922 strcpy (Filename, Gbl_DirectoryPath);
923 strcat (Filename, (char *) Child->Asl.Value.Buffer);
925 Gbl_OutputFilenamePrefix = Filename;
926 UtConvertBackslashes (Gbl_OutputFilenamePrefix);
929 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
933 Child = Child->Asl.Next;
934 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
935 if (Child->Asl.Value.String)
937 Gbl_TableSignature = Child->Asl.Value.String;
938 if (strlen (Gbl_TableSignature) != ACPI_NAME_SIZE)
940 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
941 "Length is not exactly 4");
944 for (i = 0; i < ACPI_NAME_SIZE; i++)
946 if (!isalnum ((int) Gbl_TableSignature[i]))
948 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
949 "Contains non-alphanumeric characters");
956 Child = Child->Asl.Next;
957 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
959 * We used the revision to set the integer width earlier
964 Child = Child->Asl.Next;
965 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
969 Child = Child->Asl.Next;
970 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
971 if (Child->Asl.Value.String)
973 Length = strlen (Child->Asl.Value.String);
974 Gbl_TableId = UtStringCacheCalloc (Length + 1);
975 strcpy (Gbl_TableId, Child->Asl.Value.String);
978 * Convert anything non-alphanumeric to an underscore. This
979 * allows us to use the TableID to generate unique C symbols.
981 for (i = 0; i < Length; i++)
983 if (!isalnum ((int) Gbl_TableId[i]))
985 Gbl_TableId[i] = '_';
992 Child = Child->Asl.Next;
993 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
997 /*******************************************************************************
1001 * PARAMETERS: Op - Get an argument for this op
1002 * Argn - Nth argument to get
1004 * RETURN: The argument (as an Op object). NULL if argument does not exist
1006 * DESCRIPTION: Get the specified op's argument (peer)
1008 ******************************************************************************/
1012 ACPI_PARSE_OBJECT *Op,
1015 ACPI_PARSE_OBJECT *Arg = NULL;
1018 /* Get the requested argument object */
1020 Arg = Op->Asl.Child;
1024 Arg = Arg->Asl.Next;
1031 /*******************************************************************************
1033 * FUNCTION: OpnAttachNameToNode
1035 * PARAMETERS: Op - The parent parse node
1039 * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1040 * argument list and attach it to the parent node so that we
1041 * can get to it quickly later.
1043 ******************************************************************************/
1046 OpnAttachNameToNode (
1047 ACPI_PARSE_OBJECT *Op)
1049 ACPI_PARSE_OBJECT *Child = NULL;
1052 switch (Op->Asl.AmlOpcode)
1054 case AML_DATA_REGION_OP:
1057 case AML_EXTERNAL_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_DEFINITION_BLOCK:
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:
1195 OpnAttachNameToNode (Op);