2 /******************************************************************************
4 * Module Name: aslresource - Resource template/descriptor utilities
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
118 #include <contrib/dev/acpica/compiler/aslcompiler.h>
119 #include "aslcompiler.y.h"
120 #include <contrib/dev/acpica/include/amlcode.h>
123 #define _COMPONENT ACPI_COMPILER
124 ACPI_MODULE_NAME ("aslresource")
127 /*******************************************************************************
129 * FUNCTION: RsSmallAddressCheck
131 * PARAMETERS: Minimum - Address Min value
132 * Maximum - Address Max value
133 * Length - Address range value
134 * Alignment - Address alignment value
135 * MinOp - Original Op for Address Min
136 * MaxOp - Original Op for Address Max
137 * LengthOp - Original Op for address range
138 * AlignOp - Original Op for address alignment. If
139 * NULL, means "zero value for alignment is
140 * OK, and means 64K alignment" (for
141 * Memory24 descriptor)
142 * Op - Parent Op for entire construct
144 * RETURN: None. Adds error messages to error log if necessary
146 * DESCRIPTION: Perform common value checks for "small" address descriptors.
148 * Io, Memory24, Memory32
150 ******************************************************************************/
153 RsSmallAddressCheck (
159 ACPI_PARSE_OBJECT *MinOp,
160 ACPI_PARSE_OBJECT *MaxOp,
161 ACPI_PARSE_OBJECT *LengthOp,
162 ACPI_PARSE_OBJECT *AlignOp,
163 ACPI_PARSE_OBJECT *Op)
166 if (Gbl_NoResourceChecking)
172 * Check for a so-called "null descriptor". These are descriptors that are
173 * created with most fields set to zero. The intent is that the descriptor
174 * will be updated/completed at runtime via a BufferField.
176 * If the descriptor does NOT have a resource tag, it cannot be referenced
177 * by a BufferField and we will flag this as an error. Conversely, if
178 * the descriptor has a resource tag, we will assume that a BufferField
179 * will be used to dynamically update it, so no error.
181 * A possible enhancement to this check would be to verify that in fact
182 * a BufferField is created using the resource tag, and perhaps even
183 * verify that a Store is performed to the BufferField.
185 * Note: for these descriptors, Alignment is allowed to be zero
187 if (!Minimum && !Maximum && !Length)
189 if (!Op->Asl.ExternalName)
191 /* No resource tag. Descriptor is fixed and is also illegal */
193 AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL);
199 /* Special case for Memory24, values are compressed */
201 if (Type == ACPI_RESOURCE_NAME_MEMORY24)
203 if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */
205 Alignment = ACPI_UINT16_MAX + 1;
213 /* IO descriptor has different definition of min/max, don't check */
215 if (Type != ACPI_RESOURCE_NAME_IO)
217 /* Basic checks on Min/Max/Length */
219 if (Minimum > Maximum)
221 AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL);
223 else if (Length > (Maximum - Minimum + 1))
225 AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL);
229 /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */
236 /* Addresses must be an exact multiple of the alignment value */
238 if (Minimum % Alignment)
240 AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL);
242 if (Maximum % Alignment)
244 AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, NULL);
249 /*******************************************************************************
251 * FUNCTION: RsLargeAddressCheck
253 * PARAMETERS: Minimum - Address Min value
254 * Maximum - Address Max value
255 * Length - Address range value
256 * Granularity - Address granularity value
257 * Flags - General flags for address descriptors:
259 * MinOp - Original Op for Address Min
260 * MaxOp - Original Op for Address Max
261 * LengthOp - Original Op for address range
262 * GranOp - Original Op for address granularity
263 * Op - Parent Op for entire construct
265 * RETURN: None. Adds error messages to error log if necessary
267 * DESCRIPTION: Perform common value checks for "large" address descriptors.
269 * WordIo, WordBusNumber, WordSpace
270 * DWordIo, DWordMemory, DWordSpace
271 * QWordIo, QWordMemory, QWordSpace
272 * ExtendedIo, ExtendedMemory, ExtendedSpace
274 * _MIF flag set means that the minimum address is fixed and is not relocatable
275 * _MAF flag set means that the maximum address is fixed and is not relocatable
276 * Length of zero means that the record size is variable
278 * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40
279 * of the ACPI 4.0a specification. Added 04/2010.
281 ******************************************************************************/
284 RsLargeAddressCheck (
290 ACPI_PARSE_OBJECT *MinOp,
291 ACPI_PARSE_OBJECT *MaxOp,
292 ACPI_PARSE_OBJECT *LengthOp,
293 ACPI_PARSE_OBJECT *GranOp,
294 ACPI_PARSE_OBJECT *Op)
297 if (Gbl_NoResourceChecking)
303 * Check for a so-called "null descriptor". These are descriptors that are
304 * created with most fields set to zero. The intent is that the descriptor
305 * will be updated/completed at runtime via a BufferField.
307 * If the descriptor does NOT have a resource tag, it cannot be referenced
308 * by a BufferField and we will flag this as an error. Conversely, if
309 * the descriptor has a resource tag, we will assume that a BufferField
310 * will be used to dynamically update it, so no error.
312 * A possible enhancement to this check would be to verify that in fact
313 * a BufferField is created using the resource tag, and perhaps even
314 * verify that a Store is performed to the BufferField.
316 if (!Minimum && !Maximum && !Length && !Granularity)
318 if (!Op->Asl.ExternalName)
320 /* No resource tag. Descriptor is fixed and is also illegal */
322 AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL);
328 /* Basic checks on Min/Max/Length */
330 if (Minimum > Maximum)
332 AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL);
335 else if (Length > (Maximum - Minimum + 1))
337 AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL);
341 /* If specified (non-zero), ensure granularity is a power-of-two minus one */
345 if ((Granularity + 1) &
348 AslError (ASL_ERROR, ASL_MSG_INVALID_GRANULARITY, GranOp, NULL);
354 * Check the various combinations of Length, MinFixed, and MaxFixed
358 /* Fixed non-zero length */
360 switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF))
364 * Fixed length, variable locations (both _MIN and _MAX).
365 * Length must be a multiple of granularity
367 if (Granularity & Length)
369 AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, LengthOp, NULL);
373 case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF):
375 /* Fixed length, fixed location. Granularity must be zero */
377 if (Granularity != 0)
379 AslError (ASL_ERROR, ASL_MSG_INVALID_GRAN_FIXED, GranOp, NULL);
382 /* Length must be exactly the size of the min/max window */
384 if (Length != (Maximum - Minimum + 1))
386 AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH_FIXED, LengthOp, NULL);
390 /* All other combinations are invalid */
392 case ACPI_RESOURCE_FLAG_MIF:
393 case ACPI_RESOURCE_FLAG_MAF:
395 AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL);
400 /* Variable length (length==0) */
402 switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF))
406 * Both _MIN and _MAX are variable.
407 * No additional requirements, just exit
411 case ACPI_RESOURCE_FLAG_MIF:
413 /* _MIN is fixed. _MIN must be multiple of _GRA */
416 * The granularity is defined by the ACPI specification to be a
417 * power-of-two minus one, therefore the granularity is a
418 * bitmask which can be used to easily validate the addresses.
420 if (Granularity & Minimum)
422 AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL);
426 case ACPI_RESOURCE_FLAG_MAF:
428 /* _MAX is fixed. (_MAX + 1) must be multiple of _GRA */
430 if (Granularity & (Maximum + 1))
432 AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, "-1");
436 /* Both MIF/MAF set is invalid if length is zero */
438 case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF):
440 AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL);
446 /*******************************************************************************
448 * FUNCTION: RsGetStringDataLength
450 * PARAMETERS: InitializerOp - Start of a subtree of init nodes
452 * RETURN: Valid string length if a string node is found (otherwise 0)
454 * DESCRIPTION: In a list of peer nodes, find the first one that contains a
455 * string and return the length of the string.
457 ******************************************************************************/
460 RsGetStringDataLength (
461 ACPI_PARSE_OBJECT *InitializerOp)
464 while (InitializerOp)
466 if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
468 return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1));
470 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
477 /*******************************************************************************
479 * FUNCTION: RsAllocateResourceNode
481 * PARAMETERS: Size - Size of node in bytes
483 * RETURN: The allocated node - aborts on allocation failure
485 * DESCRIPTION: Allocate a resource description node and the resource
486 * descriptor itself (the nodes are used to link descriptors).
488 ******************************************************************************/
491 RsAllocateResourceNode (
494 ASL_RESOURCE_NODE *Rnode;
497 /* Allocate the node */
499 Rnode = UtLocalCalloc (sizeof (ASL_RESOURCE_NODE));
501 /* Allocate the resource descriptor itself */
503 Rnode->Buffer = UtLocalCalloc (Size);
504 Rnode->BufferLength = Size;
510 /*******************************************************************************
512 * FUNCTION: RsCreateBitField
514 * PARAMETERS: Op - Resource field node
515 * Name - Name of the field (Used only to reference
516 * the field in the ASL, not in the AML)
517 * ByteOffset - Offset from the field start
518 * BitOffset - Additional bit offset
520 * RETURN: None, sets fields within the input node
522 * DESCRIPTION: Utility function to generate a named bit field within a
523 * resource descriptor. Mark a node as 1) a field in a resource
524 * descriptor, and 2) set the value to be a BIT offset
526 ******************************************************************************/
530 ACPI_PARSE_OBJECT *Op,
536 Op->Asl.ExternalName = Name;
537 Op->Asl.Value.Integer = ((UINT64) ByteOffset * 8) + BitOffset;
538 Op->Asl.CompileFlags |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET);
542 /*******************************************************************************
544 * FUNCTION: RsCreateByteField
546 * PARAMETERS: Op - Resource field node
547 * Name - Name of the field (Used only to reference
548 * the field in the ASL, not in the AML)
549 * ByteOffset - Offset from the field start
551 * RETURN: None, sets fields within the input node
553 * DESCRIPTION: Utility function to generate a named byte field within a
554 * resource descriptor. Mark a node as 1) a field in a resource
555 * descriptor, and 2) set the value to be a BYTE offset
557 ******************************************************************************/
561 ACPI_PARSE_OBJECT *Op,
566 Op->Asl.ExternalName = Name;
567 Op->Asl.Value.Integer = ByteOffset;
568 Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
572 /*******************************************************************************
574 * FUNCTION: RsSetFlagBits
576 * PARAMETERS: *Flags - Pointer to the flag byte
577 * Op - Flag initialization node
578 * Position - Bit position within the flag byte
579 * Default - Used if the node is DEFAULT.
581 * RETURN: Sets bits within the *Flags output byte.
583 * DESCRIPTION: Set a bit in a cumulative flags word from an initialization
584 * node. Will use a default value if the node is DEFAULT, meaning
585 * that no value was specified in the ASL. Used to merge multiple
586 * keywords into a single flags byte.
588 ******************************************************************************/
593 ACPI_PARSE_OBJECT *Op,
598 if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
600 /* Use the default bit */
602 *Flags |= (DefaultBit << Position);
606 /* Use the bit specified in the initialization node */
608 *Flags |= (((UINT8) Op->Asl.Value.Integer) << Position);
613 /*******************************************************************************
615 * FUNCTION: RsCompleteNodeAndGetNext
617 * PARAMETERS: Op - Resource node to be completed
619 * RETURN: The next peer to the input node.
621 * DESCRIPTION: Mark the current node completed and return the next peer.
622 * The node ParseOpcode is set to DEFAULT_ARG, meaning that
623 * this node is to be ignored from now on.
625 ******************************************************************************/
628 RsCompleteNodeAndGetNext (
629 ACPI_PARSE_OBJECT *Op)
632 /* Mark this node unused */
634 Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
636 /* Move on to the next peer node in the initializer list */
638 return (ASL_GET_PEER_NODE (Op));
642 /*******************************************************************************
644 * FUNCTION: RsCheckListForDuplicates
646 * PARAMETERS: Op - First op in the initializer list
650 * DESCRIPTION: Check an initializer list for duplicate values. Emits an error
651 * if any duplicates are found.
653 ******************************************************************************/
656 RsCheckListForDuplicates (
657 ACPI_PARSE_OBJECT *Op)
659 ACPI_PARSE_OBJECT *NextValueOp = Op;
660 ACPI_PARSE_OBJECT *NextOp;
669 /* Search list once for each value in the list */
673 Value = (UINT32) NextValueOp->Asl.Value.Integer;
675 /* Compare this value to all remaining values in the list */
677 NextOp = ASL_GET_PEER_NODE (NextValueOp);
680 if (NextOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
684 if (Value == (UINT32) NextOp->Asl.Value.Integer)
686 /* Emit error only once per duplicate node */
688 if (!(NextOp->Asl.CompileFlags & NODE_IS_DUPLICATE))
690 NextOp->Asl.CompileFlags |= NODE_IS_DUPLICATE;
691 AslError (ASL_ERROR, ASL_MSG_DUPLICATE_ITEM,
697 NextOp = ASL_GET_PEER_NODE (NextOp);
700 NextValueOp = ASL_GET_PEER_NODE (NextValueOp);
705 /*******************************************************************************
707 * FUNCTION: RsDoOneResourceDescriptor
709 * PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor
710 * CurrentByteOffset - Offset in the resource descriptor
713 * RETURN: A valid resource node for the descriptor
715 * DESCRIPTION: Dispatches the processing of one resource descriptor
717 ******************************************************************************/
720 RsDoOneResourceDescriptor (
721 ACPI_PARSE_OBJECT *DescriptorTypeOp,
722 UINT32 CurrentByteOffset,
725 ASL_RESOURCE_NODE *Rnode = NULL;
728 /* Construct the resource */
730 switch (DescriptorTypeOp->Asl.ParseOpcode)
733 Rnode = RsDoDmaDescriptor (DescriptorTypeOp,
737 case PARSEOP_DWORDIO:
738 Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp,
742 case PARSEOP_DWORDMEMORY:
743 Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp,
747 case PARSEOP_DWORDSPACE:
748 Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp,
752 case PARSEOP_ENDDEPENDENTFN:
755 case ACPI_RSTATE_NORMAL:
756 AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT,
757 DescriptorTypeOp, NULL);
760 case ACPI_RSTATE_START_DEPENDENT:
761 AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
762 DescriptorTypeOp, NULL);
765 case ACPI_RSTATE_DEPENDENT_LIST:
770 *State = ACPI_RSTATE_NORMAL;
771 Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp,
776 Rnode = RsDoEndTagDescriptor (DescriptorTypeOp,
780 case PARSEOP_EXTENDEDIO:
781 Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp,
785 case PARSEOP_EXTENDEDMEMORY:
786 Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp,
790 case PARSEOP_EXTENDEDSPACE:
791 Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp,
795 case PARSEOP_FIXEDIO:
796 Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp,
800 case PARSEOP_INTERRUPT:
801 Rnode = RsDoInterruptDescriptor (DescriptorTypeOp,
806 Rnode = RsDoIoDescriptor (DescriptorTypeOp,
811 Rnode = RsDoIrqDescriptor (DescriptorTypeOp,
815 case PARSEOP_IRQNOFLAGS:
816 Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp,
820 case PARSEOP_MEMORY24:
821 Rnode = RsDoMemory24Descriptor (DescriptorTypeOp,
825 case PARSEOP_MEMORY32:
826 Rnode = RsDoMemory32Descriptor (DescriptorTypeOp,
830 case PARSEOP_MEMORY32FIXED:
831 Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp,
835 case PARSEOP_QWORDIO:
836 Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp,
840 case PARSEOP_QWORDMEMORY:
841 Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp,
845 case PARSEOP_QWORDSPACE:
846 Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp,
850 case PARSEOP_REGISTER:
851 Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp,
855 case PARSEOP_STARTDEPENDENTFN:
858 case ACPI_RSTATE_START_DEPENDENT:
859 AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
860 DescriptorTypeOp, NULL);
863 case ACPI_RSTATE_NORMAL:
864 case ACPI_RSTATE_DEPENDENT_LIST:
869 *State = ACPI_RSTATE_START_DEPENDENT;
870 Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp,
872 *State = ACPI_RSTATE_DEPENDENT_LIST;
875 case PARSEOP_STARTDEPENDENTFN_NOPRI:
878 case ACPI_RSTATE_START_DEPENDENT:
879 AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
880 DescriptorTypeOp, NULL);
883 case ACPI_RSTATE_NORMAL:
884 case ACPI_RSTATE_DEPENDENT_LIST:
889 *State = ACPI_RSTATE_START_DEPENDENT;
890 Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp,
892 *State = ACPI_RSTATE_DEPENDENT_LIST;
895 case PARSEOP_VENDORLONG:
896 Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp,
900 case PARSEOP_VENDORSHORT:
901 Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp,
905 case PARSEOP_WORDBUSNUMBER:
906 Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp,
911 Rnode = RsDoWordIoDescriptor (DescriptorTypeOp,
915 case PARSEOP_WORDSPACE:
916 Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp,
920 case PARSEOP_DEFAULT_ARG:
921 /* Just ignore any of these, they are used as fillers/placeholders */
925 printf ("Unknown resource descriptor type [%s]\n",
926 DescriptorTypeOp->Asl.ParseOpName);
931 * Mark original node as unused, but head of a resource descriptor.
932 * This allows the resource to be installed in the namespace so that
933 * references to the descriptor can be resolved.
935 DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
936 DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC;
937 DescriptorTypeOp->Asl.Value.Integer = CurrentByteOffset;
941 DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength;
948 /*******************************************************************************
950 * FUNCTION: RsLinkDescriptorChain
952 * PARAMETERS: PreviousRnode - Pointer to the node that will be previous
953 * to the linked node, At exit, set to the
954 * last node in the new chain.
955 * Rnode - Resource node to link into the list
957 * RETURN: Cumulative buffer byte offset of the new segment of chain
959 * DESCRIPTION: Link a descriptor chain at the end of an existing chain.
961 ******************************************************************************/
964 RsLinkDescriptorChain (
965 ASL_RESOURCE_NODE **PreviousRnode,
966 ASL_RESOURCE_NODE *Rnode)
968 ASL_RESOURCE_NODE *LastRnode;
969 UINT32 CurrentByteOffset;
972 /* Anything to do? */
979 /* Point the previous node to the new node */
981 (*PreviousRnode)->Next = Rnode;
982 CurrentByteOffset = Rnode->BufferLength;
984 /* Walk to the end of the chain headed by Rnode */
987 while (LastRnode->Next)
989 LastRnode = LastRnode->Next;
990 CurrentByteOffset += LastRnode->BufferLength;
993 /* Previous node becomes the last node in the chain */
995 *PreviousRnode = LastRnode;
996 return CurrentByteOffset;
1000 /*******************************************************************************
1002 * FUNCTION: RsDoResourceTemplate
1004 * PARAMETERS: Op - Parent of a resource template list
1006 * RETURN: None. Sets input node to point to a list of AML code
1008 * DESCRIPTION: Merge a list of resource descriptors into a single AML buffer,
1009 * in preparation for output to the AML output file.
1011 ******************************************************************************/
1014 RsDoResourceTemplate (
1015 ACPI_PARSE_OBJECT *Op)
1017 ACPI_PARSE_OBJECT *BufferLengthOp;
1018 ACPI_PARSE_OBJECT *BufferOp;
1019 ACPI_PARSE_OBJECT *DescriptorTypeOp;
1020 ACPI_PARSE_OBJECT *LastOp = NULL;
1021 UINT32 CurrentByteOffset = 0;
1022 ASL_RESOURCE_NODE HeadRnode;
1023 ASL_RESOURCE_NODE *PreviousRnode;
1024 ASL_RESOURCE_NODE *Rnode;
1028 /* Mark parent as containing a resource template */
1032 Op->Asl.Parent->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC;
1035 /* ResourceTemplate Opcode is first (Op) */
1036 /* Buffer Length node is first child */
1038 BufferLengthOp = ASL_GET_CHILD_NODE (Op);
1040 /* Buffer Op is first peer */
1042 BufferOp = ASL_GET_PEER_NODE (BufferLengthOp);
1044 /* First Descriptor type is next */
1046 DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp);
1049 * Process all resource descriptors in the list
1050 * Note: It is assumed that the EndTag node has been automatically
1051 * inserted at the end of the template by the parser.
1053 State = ACPI_RSTATE_NORMAL;
1054 PreviousRnode = &HeadRnode;
1055 while (DescriptorTypeOp)
1057 DescriptorTypeOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC;
1058 Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset,
1062 * Update current byte offset to indicate the number of bytes from the
1063 * start of the buffer. Buffer can include multiple descriptors, we
1064 * must keep track of the offset of not only each descriptor, but each
1065 * element (field) within each descriptor as well.
1067 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
1069 /* Get the next descriptor in the list */
1071 LastOp = DescriptorTypeOp;
1072 DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp);
1075 if (State == ACPI_RSTATE_DEPENDENT_LIST)
1079 LastOp = LastOp->Asl.Parent;
1081 AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL);
1085 * Transform the nodes into the following
1087 * Op -> AML_BUFFER_OP
1088 * First Child -> BufferLength
1089 * Second Child -> Descriptor Buffer (raw byte data)
1091 Op->Asl.ParseOpcode = PARSEOP_BUFFER;
1092 Op->Asl.AmlOpcode = AML_BUFFER_OP;
1093 Op->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC;
1095 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
1096 BufferLengthOp->Asl.Value.Integer = CurrentByteOffset;
1097 (void) OpcSetOptimalIntegerSize (BufferLengthOp);
1099 BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
1100 BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
1101 BufferOp->Asl.AmlOpcodeLength = 0;
1102 BufferOp->Asl.AmlLength = CurrentByteOffset;
1103 BufferOp->Asl.Value.Buffer = (UINT8 *) HeadRnode.Next;
1104 BufferOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DATA;