2 /******************************************************************************
4 * Module Name: asloperands - AML operand processing
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
46 #include <contrib/dev/acpica/compiler/aslcompiler.h>
47 #include "aslcompiler.y.h"
48 #include <contrib/dev/acpica/include/amlcode.h>
50 #define _COMPONENT ACPI_COMPILER
51 ACPI_MODULE_NAME ("asloperands")
53 /* Local prototypes */
57 ACPI_PARSE_OBJECT *Op);
61 ACPI_PARSE_OBJECT *Op);
65 ACPI_PARSE_OBJECT *Op);
68 OpnDoDefinitionBlock (
69 ACPI_PARSE_OBJECT *Op);
73 ACPI_PARSE_OBJECT *FieldOp,
74 ACPI_PARSE_OBJECT *Op);
78 ACPI_PARSE_OBJECT *Op);
82 ACPI_PARSE_OBJECT *Op);
86 ACPI_PARSE_OBJECT *Op);
90 ACPI_PARSE_OBJECT *Op);
94 ACPI_PARSE_OBJECT *Op);
98 ACPI_PARSE_OBJECT *Op);
101 /*******************************************************************************
103 * FUNCTION: OpnDoMutex
105 * PARAMETERS: Op - The parent parse node
109 * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
111 ******************************************************************************/
115 ACPI_PARSE_OBJECT *Op)
117 ACPI_PARSE_OBJECT *Next;
120 Next = Op->Asl.Child;
121 Next = Next->Asl.Next;
123 if (Next->Asl.Value.Integer > 15)
125 AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
131 /*******************************************************************************
133 * FUNCTION: OpnDoMethod
135 * PARAMETERS: Op - The parent parse node
139 * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
141 ******************************************************************************/
145 ACPI_PARSE_OBJECT *Op)
147 ACPI_PARSE_OBJECT *Next;
149 /* Optional arguments for this opcode with defaults */
152 UINT8 Serialized = 0;
153 UINT8 Concurrency = 0;
157 /* Opcode and package length first */
160 Next = Op->Asl.Child;
164 Next = Next->Asl.Next;
165 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
167 NumArgs = (UINT8) Next->Asl.Value.Integer;
168 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
171 /* Serialized Flag */
173 Next = Next->Asl.Next;
174 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
176 Serialized = (UINT8) Next->Asl.Value.Integer;
177 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
180 /* Concurrency value (valid values are 0-15) */
182 Next = Next->Asl.Next;
183 if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
185 if (Next->Asl.Value.Integer > 15)
187 AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
189 Concurrency = (UINT8) Next->Asl.Value.Integer;
192 /* Put the bits in their proper places */
194 MethodFlags = (UINT8) ((NumArgs & 0x7) |
195 ((Serialized & 0x1) << 3) |
196 ((Concurrency & 0xF) << 4));
198 /* Use the last node for the combined flags byte */
200 Next->Asl.Value.Integer = MethodFlags;
201 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
202 Next->Asl.AmlLength = 1;
203 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
205 /* Save the arg count in the first node */
207 Op->Asl.Extra = NumArgs;
211 /*******************************************************************************
213 * FUNCTION: OpnDoFieldCommon
215 * PARAMETERS: FieldOp - Node for an ASL field
216 * Op - The parent parse node
220 * DESCRIPTION: Construct the AML operands for the various field keywords,
221 * FIELD, BANKFIELD, INDEXFIELD
223 ******************************************************************************/
227 ACPI_PARSE_OBJECT *FieldOp,
228 ACPI_PARSE_OBJECT *Op)
230 ACPI_PARSE_OBJECT *Next;
231 ACPI_PARSE_OBJECT *PkgLengthNode;
232 UINT32 CurrentBitOffset;
238 UINT32 MinimumLength;
241 /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
243 AccessType = (UINT8) Op->Asl.Value.Integer;
244 Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
246 /* Set the access type in the parent (field) node for use later */
248 FieldOp->Asl.Value.Integer = AccessType;
250 /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
253 LockRule = (UINT8) Next->Asl.Value.Integer;
254 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
256 /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
258 Next = Next->Asl.Next;
259 UpdateRule = (UINT8) Next->Asl.Value.Integer;
262 * Generate the flags byte. The various fields are already
263 * in the right bit position via translation from the
264 * keywords by the parser.
266 FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule);
268 /* Use the previous node to be the FieldFlags node */
270 /* Set the node to RAW_DATA */
272 Next->Asl.Value.Integer = FieldFlags;
273 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
274 Next->Asl.AmlLength = 1;
275 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
277 /* Process the FieldUnitList */
279 Next = Next->Asl.Next;
280 CurrentBitOffset = 0;
284 /* Save the offset of this field unit */
286 Next->Asl.ExtraValue = CurrentBitOffset;
288 switch (Next->Asl.ParseOpcode)
290 case PARSEOP_ACCESSAS:
292 PkgLengthNode = Next->Asl.Child;
293 AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer;
295 /* Nothing additional to do */
301 /* New offset into the field */
303 PkgLengthNode = Next->Asl.Child;
304 NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8;
307 * Examine the specified offset in relation to the
308 * current offset counter.
310 if (NewBitOffset < CurrentBitOffset)
313 * Not allowed to specify a backwards offset!
314 * Issue error and ignore this node.
316 AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode,
318 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
319 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
321 else if (NewBitOffset == CurrentBitOffset)
324 * Offset is redundant; we don't need to output an
325 * offset opcode. Just set these nodes to default
327 Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
328 PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
333 * Valid new offset - set the value to be inserted into the AML
334 * and update the offset counter.
336 PkgLengthNode->Asl.Value.Integer =
337 NewBitOffset - CurrentBitOffset;
338 CurrentBitOffset = NewBitOffset;
343 case PARSEOP_NAMESEG:
344 case PARSEOP_RESERVED_BYTES:
346 /* Named or reserved field entry */
348 PkgLengthNode = Next->Asl.Child;
349 NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer;
350 CurrentBitOffset += NewBitOffset;
352 /* Save the current AccessAs value for error checking later */
356 case AML_FIELD_ACCESS_ANY:
357 case AML_FIELD_ACCESS_BYTE:
358 case AML_FIELD_ACCESS_BUFFER:
363 case AML_FIELD_ACCESS_WORD:
367 case AML_FIELD_ACCESS_DWORD:
371 case AML_FIELD_ACCESS_QWORD:
376 PkgLengthNode->Asl.ExtraValue = MinimumLength;
380 /* All supported field opcodes must appear above */
384 /* Move on to next entry in the field list */
386 Next = Next->Asl.Next;
391 /*******************************************************************************
393 * FUNCTION: OpnDoField
395 * PARAMETERS: Op - The parent parse node
399 * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
401 ******************************************************************************/
405 ACPI_PARSE_OBJECT *Op)
407 ACPI_PARSE_OBJECT *Next;
410 /* Opcode is parent node */
411 /* First child is field name */
413 Next = Op->Asl.Child;
415 /* Second child is the AccessType */
417 OpnDoFieldCommon (Op, Next->Asl.Next);
421 /*******************************************************************************
423 * FUNCTION: OpnDoIndexField
425 * PARAMETERS: Op - The parent parse node
429 * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
431 ******************************************************************************/
435 ACPI_PARSE_OBJECT *Op)
437 ACPI_PARSE_OBJECT *Next;
440 /* Opcode is parent node */
441 /* First child is the index name */
443 Next = Op->Asl.Child;
445 /* Second child is the data name */
447 Next = Next->Asl.Next;
449 /* Third child is the AccessType */
451 OpnDoFieldCommon (Op, Next->Asl.Next);
455 /*******************************************************************************
457 * FUNCTION: OpnDoBankField
459 * PARAMETERS: Op - The parent parse node
463 * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
465 ******************************************************************************/
469 ACPI_PARSE_OBJECT *Op)
471 ACPI_PARSE_OBJECT *Next;
474 /* Opcode is parent node */
475 /* First child is the region name */
477 Next = Op->Asl.Child;
479 /* Second child is the bank name */
481 Next = Next->Asl.Next;
483 /* Third child is the bank value */
485 Next = Next->Asl.Next;
487 /* Fourth child is the AccessType */
489 OpnDoFieldCommon (Op, Next->Asl.Next);
493 /*******************************************************************************
495 * FUNCTION: OpnDoRegion
497 * PARAMETERS: Op - The parent parse node
501 * DESCRIPTION: Tries to get the length of the region. Can only do this at
502 * compile time if the length is a constant.
504 ******************************************************************************/
508 ACPI_PARSE_OBJECT *Op)
510 ACPI_PARSE_OBJECT *Next;
513 /* Opcode is parent node */
514 /* First child is the region name */
516 Next = Op->Asl.Child;
518 /* Second child is the space ID*/
520 Next = Next->Asl.Next;
522 /* Third child is the region offset */
524 Next = Next->Asl.Next;
526 /* Fourth child is the region length */
528 Next = Next->Asl.Next;
529 if (Next->Asl.ParseOpcode == PARSEOP_INTEGER)
531 Op->Asl.Value.Integer = Next->Asl.Value.Integer;
535 Op->Asl.Value.Integer = ACPI_UINT64_MAX;
540 /*******************************************************************************
542 * FUNCTION: OpnDoBuffer
544 * PARAMETERS: Op - The parent parse node
548 * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
549 * build a single raw byte buffer from the initialization nodes,
550 * each parse node contains a buffer byte.
552 ******************************************************************************/
556 ACPI_PARSE_OBJECT *Op)
558 ACPI_PARSE_OBJECT *InitializerOp;
559 ACPI_PARSE_OBJECT *BufferLengthOp;
561 /* Optional arguments for this opcode with defaults */
563 UINT32 BufferLength = 0;
566 /* Opcode and package length first */
567 /* Buffer Length is next, followed by the initializer list */
569 BufferLengthOp = Op->Asl.Child;
570 InitializerOp = BufferLengthOp->Asl.Next;
573 * If the BufferLength is not an INTEGER or was not specified in the ASL
574 * (DEFAULT_ARG), it is a TermArg that is
575 * evaluated at run-time, and we are therefore finished.
577 if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
578 (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
584 * We want to count the number of items in the initializer list, because if
585 * it is larger than the buffer length, we will define the buffer size
586 * to be the size of the initializer list (as per the ACPI Specification)
588 switch (InitializerOp->Asl.ParseOpcode)
590 case PARSEOP_INTEGER:
591 case PARSEOP_BYTECONST:
592 case PARSEOP_WORDCONST:
593 case PARSEOP_DWORDCONST:
595 /* The peer list contains the byte list (if any...) */
597 while (InitializerOp)
599 /* For buffers, this is a list of raw bytes */
601 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
602 InitializerOp->Asl.AmlLength = 1;
603 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
606 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
611 case PARSEOP_STRING_LITERAL:
614 * Only one initializer, the string. Buffer must be big enough to hold
615 * the string plus the null termination byte
617 BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
619 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
620 InitializerOp->Asl.AmlLength = BufferLength;
621 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
625 case PARSEOP_RAW_DATA:
627 /* Buffer nodes are already initialized (e.g. Unicode operator) */
631 case PARSEOP_DEFAULT_ARG:
636 AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
637 "Unknown buffer initializer opcode");
638 printf ("Unknown buffer initializer opcode [%s]\n",
639 UtGetOpName (InitializerOp->Asl.ParseOpcode));
643 /* Check if initializer list is longer than the buffer length */
645 if (BufferLengthOp->Asl.Value.Integer > BufferLength)
647 BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
652 /* No length AND no items -- issue notice */
654 AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
656 /* But go ahead and put the buffer length of zero into the AML */
660 * Just set the buffer size node to be the buffer length, regardless
661 * of whether it was previously an integer or a default_arg placeholder
663 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
664 BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
665 BufferLengthOp->Asl.Value.Integer = BufferLength;
667 (void) OpcSetOptimalIntegerSize (BufferLengthOp);
669 /* Remaining nodes are handled via the tree walk */
673 /*******************************************************************************
675 * FUNCTION: OpnDoPackage
677 * PARAMETERS: Op - The parent parse node
681 * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
682 * can only be called after constants have been folded, to ensure
683 * that the PackageLength operand has been fully reduced.
685 ******************************************************************************/
689 ACPI_PARSE_OBJECT *Op)
691 ACPI_PARSE_OBJECT *InitializerOp;
692 ACPI_PARSE_OBJECT *PackageLengthOp;
693 UINT32 PackageLength = 0;
696 /* Opcode and package length first, followed by the initializer list */
698 PackageLengthOp = Op->Asl.Child;
699 InitializerOp = PackageLengthOp->Asl.Next;
701 /* Count the number of items in the initializer list */
703 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
705 /* The peer list contains the byte list (if any...) */
707 while (InitializerOp)
710 InitializerOp = InitializerOp->Asl.Next;
714 /* If package length is a constant, compare to the initializer list */
716 if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
717 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST))
719 if (PackageLengthOp->Asl.Value.Integer > PackageLength)
722 * Allow package length to be longer than the initializer
723 * list -- but if the length of initializer list is nonzero,
724 * issue a message since this is probably a coding error,
725 * even though technically legal.
727 if (PackageLength > 0)
729 AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT,
730 PackageLengthOp, NULL);
733 PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer;
735 else if (PackageLengthOp->Asl.Value.Integer < PackageLength)
738 * The package length is smaller than the length of the
739 * initializer list. This is an error as per the ACPI spec.
741 AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG,
742 PackageLengthOp, NULL);
746 if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
749 * This is the case if the PackageLength was left empty - Package()
750 * The package length becomes the length of the initializer list
752 Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
753 Op->Asl.Child->Asl.Value.Integer = PackageLength;
755 /* Set the AML opcode */
757 (void) OpcSetOptimalIntegerSize (Op->Asl.Child);
760 /* If not a variable-length package, check for a zero package length */
762 if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
763 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) ||
764 (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
768 /* No length AND no initializer list -- issue a remark */
770 AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH,
771 PackageLengthOp, NULL);
773 /* But go ahead and put the buffer length of zero into the AML */
778 * If the PackageLength is a constant <= 255, we can change the
779 * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
781 if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
782 (Op->Asl.Child->Asl.Value.Integer <= 255))
784 Op->Asl.AmlOpcode = AML_PACKAGE_OP;
785 Op->Asl.ParseOpcode = PARSEOP_PACKAGE;
788 * Just set the package size node to be the package length, regardless
789 * of whether it was previously an integer or a default_arg placeholder
791 PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
792 PackageLengthOp->Asl.AmlLength = 1;
793 PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
794 PackageLengthOp->Asl.Value.Integer = PackageLength;
797 /* Remaining nodes are handled via the tree walk */
801 /*******************************************************************************
803 * FUNCTION: OpnDoLoadTable
805 * PARAMETERS: Op - The parent parse node
809 * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
811 ******************************************************************************/
815 ACPI_PARSE_OBJECT *Op)
817 ACPI_PARSE_OBJECT *Next;
820 /* Opcode is parent node */
821 /* First child is the table signature */
823 Next = Op->Asl.Child;
825 /* Second child is the OEM ID*/
827 Next = Next->Asl.Next;
829 /* Third child is the OEM table ID */
831 Next = Next->Asl.Next;
833 /* Fourth child is the RootPath string */
835 Next = Next->Asl.Next;
836 if (Next->Asl.ParseOpcode == PARSEOP_ZERO)
838 Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
839 Next->Asl.Value.String = "\\";
840 Next->Asl.AmlLength = 2;
841 OpcGenerateAmlOpcode (Next);
844 #ifdef ASL_FUTURE_IMPLEMENTATION
846 /* TBD: NOT IMPLEMENTED */
847 /* Fifth child is the [optional] ParameterPathString */
848 /* Sixth child is the [optional] ParameterData */
850 Next = Next->Asl.Next;
851 if (Next->Asl.ParseOpcode == DEFAULT_ARG)
853 Next->Asl.AmlLength = 1;
854 Next->Asl.ParseOpcode = ZERO;
855 OpcGenerateAmlOpcode (Next);
859 Next = Next->Asl.Next;
860 if (Next->Asl.ParseOpcode == DEFAULT_ARG)
862 Next->Asl.AmlLength = 1;
863 Next->Asl.ParseOpcode = ZERO;
864 OpcGenerateAmlOpcode (Next);
870 /*******************************************************************************
872 * FUNCTION: OpnDoDefinitionBlock
874 * PARAMETERS: Op - The parent parse node
878 * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
880 ******************************************************************************/
883 OpnDoDefinitionBlock (
884 ACPI_PARSE_OBJECT *Op)
886 ACPI_PARSE_OBJECT *Child;
893 * These nodes get stuffed into the table header. They are special
894 * cased when the table is written to the output file.
896 * Mark all of these nodes as non-usable so they won't get output
900 /* Get AML filename. Use it if non-null */
902 Child = Op->Asl.Child;
903 if (Child->Asl.Value.Buffer &&
904 *Child->Asl.Value.Buffer &&
905 (Gbl_UseDefaultAmlFilename))
908 * We will use the AML filename that is embedded in the source file
909 * for the output filename.
911 Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) +
912 strlen ((char *) Child->Asl.Value.Buffer) + 1);
914 /* Prepend the current directory path */
916 strcpy (Filename, Gbl_DirectoryPath);
917 strcat (Filename, (char *) Child->Asl.Value.Buffer);
919 Gbl_OutputFilenamePrefix = Filename;
921 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
925 Child = Child->Asl.Next;
926 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
927 if (Child->Asl.Value.String)
929 Gbl_TableSignature = Child->Asl.Value.String;
930 if (ACPI_STRLEN (Gbl_TableSignature) != 4)
932 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
933 "Length not exactly 4");
936 for (i = 0; i < 4; i++)
938 if (!isalnum ((int) Gbl_TableSignature[i]))
940 AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
941 "Contains non-alphanumeric characters");
948 Child = Child->Asl.Next;
949 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
951 * We used the revision to set the integer width earlier
956 Child = Child->Asl.Next;
957 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
961 Child = Child->Asl.Next;
962 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
963 if (Child->Asl.Value.String)
965 Length = ACPI_STRLEN (Child->Asl.Value.String);
966 Gbl_TableId = AcpiOsAllocate (Length + 1);
967 ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
969 for (i = 0; i < Length; i++)
971 if (Gbl_TableId[i] == ' ')
981 Child = Child->Asl.Next;
982 Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
986 /*******************************************************************************
990 * PARAMETERS: Op - Get an argument for this op
991 * Argn - Nth argument to get
993 * RETURN: The argument (as an Op object). NULL if argument does not exist
995 * DESCRIPTION: Get the specified op's argument (peer)
997 ******************************************************************************/
1001 ACPI_PARSE_OBJECT *Op,
1004 ACPI_PARSE_OBJECT *Arg = NULL;
1007 /* Get the requested argument object */
1009 Arg = Op->Asl.Child;
1013 Arg = Arg->Asl.Next;
1020 /*******************************************************************************
1022 * FUNCTION: OpnAttachNameToNode
1024 * PARAMETERS: Op - The parent parse node
1028 * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1029 * argument list and attach it to the parent node so that we
1030 * can get to it quickly later.
1032 ******************************************************************************/
1035 OpnAttachNameToNode (
1036 ACPI_PARSE_OBJECT *Op)
1038 ACPI_PARSE_OBJECT *Child = NULL;
1041 if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)
1043 Child = UtGetArg (Op, 0);
1045 else switch (Op->Asl.AmlOpcode)
1047 case AML_DATA_REGION_OP:
1053 case AML_POWER_RES_OP:
1054 case AML_PROCESSOR_OP:
1055 case AML_THERMAL_ZONE_OP:
1059 Child = UtGetArg (Op, 0);
1064 Child = UtGetArg (Op, 1);
1067 case AML_CREATE_BIT_FIELD_OP:
1068 case AML_CREATE_BYTE_FIELD_OP:
1069 case AML_CREATE_WORD_FIELD_OP:
1070 case AML_CREATE_DWORD_FIELD_OP:
1071 case AML_CREATE_QWORD_FIELD_OP:
1073 Child = UtGetArg (Op, 2);
1076 case AML_CREATE_FIELD_OP:
1078 Child = UtGetArg (Op, 3);
1081 case AML_BANK_FIELD_OP:
1082 case AML_INDEX_FIELD_OP:
1093 UtAttachNamepathToOwner (Op, Child);
1098 /*******************************************************************************
1100 * FUNCTION: OpnGenerateAmlOperands
1102 * PARAMETERS: Op - The parent parse node
1106 * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
1107 * complex AML opcodes require processing of the child nodes
1108 * (arguments/operands).
1110 ******************************************************************************/
1113 OpnGenerateAmlOperands (
1114 ACPI_PARSE_OBJECT *Op)
1118 if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
1123 switch (Op->Asl.ParseOpcode)
1125 case PARSEOP_DEFINITIONBLOCK:
1126 OpnDoDefinitionBlock (Op);
1129 case PARSEOP_METHOD:
1141 case PARSEOP_INDEXFIELD:
1142 OpnDoIndexField (Op);
1145 case PARSEOP_BANKFIELD:
1146 OpnDoBankField (Op);
1149 case PARSEOP_BUFFER:
1153 case PARSEOP_LOADTABLE:
1154 OpnDoLoadTable (Op);
1157 case PARSEOP_OPERATIONREGION:
1161 case PARSEOP_RESOURCETEMPLATE:
1162 RsDoResourceTemplate (Op);
1165 case PARSEOP_NAMESEG:
1166 case PARSEOP_NAMESTRING:
1167 case PARSEOP_METHODCALL:
1168 case PARSEOP_STRING_LITERAL:
1177 OpnAttachNameToNode (Op);