1 /******************************************************************************
3 * Module Name: aslresource - Resource template/descriptor utilities
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
157 #define _COMPONENT ACPI_COMPILER
158 ACPI_MODULE_NAME ("aslresource")
161 /*******************************************************************************
163 * FUNCTION: RsSmallAddressCheck
165 * PARAMETERS: Minimum - Address Min value
166 * Maximum - Address Max value
167 * Length - Address range value
168 * Alignment - Address alignment value
169 * MinOp - Original Op for Address Min
170 * MaxOp - Original Op for Address Max
171 * LengthOp - Original Op for address range
172 * AlignOp - Original Op for address alignment. If
173 * NULL, means "zero value for alignment is
174 * OK, and means 64K alignment" (for
175 * Memory24 descriptor)
176 * Op - Parent Op for entire construct
178 * RETURN: None. Adds error messages to error log if necessary
180 * DESCRIPTION: Perform common value checks for "small" address descriptors.
182 * Io, Memory24, Memory32
184 ******************************************************************************/
187 RsSmallAddressCheck (
193 ACPI_PARSE_OBJECT
*MinOp
,
194 ACPI_PARSE_OBJECT
*MaxOp
,
195 ACPI_PARSE_OBJECT
*LengthOp
,
196 ACPI_PARSE_OBJECT
*AlignOp
,
197 ACPI_PARSE_OBJECT
*Op
)
200 if (Gbl_NoResourceChecking
)
206 * Check for a so-called "null descriptor". These are descriptors that are
207 * created with most fields set to zero. The intent is that the descriptor
208 * will be updated/completed at runtime via a BufferField.
210 * If the descriptor does NOT have a resource tag, it cannot be referenced
211 * by a BufferField and we will flag this as an error. Conversely, if
212 * the descriptor has a resource tag, we will assume that a BufferField
213 * will be used to dynamically update it, so no error.
215 * A possible enhancement to this check would be to verify that in fact
216 * a BufferField is created using the resource tag, and perhaps even
217 * verify that a Store is performed to the BufferField.
219 * Note: for these descriptors, Alignment is allowed to be zero
221 if (!Minimum
&& !Maximum
&& !Length
)
223 if (!Op
->Asl
.ExternalName
)
225 /* No resource tag. Descriptor is fixed and is also illegal */
227 AslError (ASL_ERROR
, ASL_MSG_NULL_DESCRIPTOR
, Op
, NULL
);
234 * Range checks for Memory24 and Memory32.
235 * IO descriptor has different definition of min/max, don't check.
237 if (Type
!= ACPI_RESOURCE_NAME_IO
)
239 /* Basic checks on Min/Max/Length */
241 if (Minimum
> Maximum
)
243 AslError (ASL_ERROR
, ASL_MSG_INVALID_MIN_MAX
, MinOp
, NULL
);
245 else if (Length
> (Maximum
- Minimum
+ 1))
247 AslError (ASL_ERROR
, ASL_MSG_INVALID_LENGTH
, LengthOp
, NULL
);
250 /* Special case for Memory24, min/max values are compressed */
252 if (Type
== ACPI_RESOURCE_NAME_MEMORY24
)
254 if (!Alignment
) /* Alignment==0 means 64K alignment */
256 Alignment
= ACPI_UINT16_MAX
+ 1;
264 /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */
271 /* Addresses must be an exact multiple of the alignment value */
273 if (Minimum
% Alignment
)
275 AslError (ASL_ERROR
, ASL_MSG_ALIGNMENT
, MinOp
, NULL
);
277 if (Maximum
% Alignment
)
279 AslError (ASL_ERROR
, ASL_MSG_ALIGNMENT
, MaxOp
, NULL
);
284 /*******************************************************************************
286 * FUNCTION: RsLargeAddressCheck
288 * PARAMETERS: Minimum - Address Min value
289 * Maximum - Address Max value
290 * Length - Address range value
291 * Granularity - Address granularity value
292 * Flags - General flags for address descriptors:
294 * MinOp - Original Op for Address Min
295 * MaxOp - Original Op for Address Max
296 * LengthOp - Original Op for address range
297 * GranOp - Original Op for address granularity
298 * Op - Parent Op for entire construct
300 * RETURN: None. Adds error messages to error log if necessary
302 * DESCRIPTION: Perform common value checks for "large" address descriptors.
304 * WordIo, WordBusNumber, WordSpace
305 * DWordIo, DWordMemory, DWordSpace
306 * QWordIo, QWordMemory, QWordSpace
307 * ExtendedIo, ExtendedMemory, ExtendedSpace
309 * _MIF flag set means that the minimum address is fixed and is not relocatable
310 * _MAF flag set means that the maximum address is fixed and is not relocatable
311 * Length of zero means that the record size is variable
313 * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40
314 * of the ACPI 4.0a specification. Added 04/2010.
316 ******************************************************************************/
319 RsLargeAddressCheck (
325 ACPI_PARSE_OBJECT
*MinOp
,
326 ACPI_PARSE_OBJECT
*MaxOp
,
327 ACPI_PARSE_OBJECT
*LengthOp
,
328 ACPI_PARSE_OBJECT
*GranOp
,
329 ACPI_PARSE_OBJECT
*Op
)
332 if (Gbl_NoResourceChecking
)
338 * Check for a so-called "null descriptor". These are descriptors that are
339 * created with most fields set to zero. The intent is that the descriptor
340 * will be updated/completed at runtime via a BufferField.
342 * If the descriptor does NOT have a resource tag, it cannot be referenced
343 * by a BufferField and we will flag this as an error. Conversely, if
344 * the descriptor has a resource tag, we will assume that a BufferField
345 * will be used to dynamically update it, so no error.
347 * A possible enhancement to this check would be to verify that in fact
348 * a BufferField is created using the resource tag, and perhaps even
349 * verify that a Store is performed to the BufferField.
351 if (!Minimum
&& !Maximum
&& !Length
&& !Granularity
)
353 if (!Op
->Asl
.ExternalName
)
355 /* No resource tag. Descriptor is fixed and is also illegal */
357 AslError (ASL_ERROR
, ASL_MSG_NULL_DESCRIPTOR
, Op
, NULL
);
363 /* Basic checks on Min/Max/Length */
365 if (Minimum
> Maximum
)
367 AslError (ASL_ERROR
, ASL_MSG_INVALID_MIN_MAX
, MinOp
, NULL
);
370 else if (Length
> (Maximum
- Minimum
+ 1))
372 AslError (ASL_ERROR
, ASL_MSG_INVALID_LENGTH
, LengthOp
, NULL
);
376 /* If specified (non-zero), ensure granularity is a power-of-two minus one */
380 if ((Granularity
+ 1) &
383 AslError (ASL_ERROR
, ASL_MSG_INVALID_GRANULARITY
, GranOp
, NULL
);
389 * Check the various combinations of Length, MinFixed, and MaxFixed
393 /* Fixed non-zero length */
395 switch (Flags
& (ACPI_RESOURCE_FLAG_MIF
| ACPI_RESOURCE_FLAG_MAF
))
399 * Fixed length, variable locations (both _MIN and _MAX).
400 * Length must be a multiple of granularity
402 if (Granularity
& Length
)
404 AslError (ASL_ERROR
, ASL_MSG_ALIGNMENT
, LengthOp
, NULL
);
408 case (ACPI_RESOURCE_FLAG_MIF
| ACPI_RESOURCE_FLAG_MAF
):
410 /* Fixed length, fixed location. Granularity must be zero */
412 if (Granularity
!= 0)
414 AslError (ASL_ERROR
, ASL_MSG_INVALID_GRAN_FIXED
, GranOp
, NULL
);
417 /* Length must be exactly the size of the min/max window */
419 if (Length
!= (Maximum
- Minimum
+ 1))
421 AslError (ASL_ERROR
, ASL_MSG_INVALID_LENGTH_FIXED
, LengthOp
, NULL
);
425 /* All other combinations are invalid */
427 case ACPI_RESOURCE_FLAG_MIF
:
428 case ACPI_RESOURCE_FLAG_MAF
:
431 AslError (ASL_ERROR
, ASL_MSG_INVALID_ADDR_FLAGS
, LengthOp
, NULL
);
436 /* Variable length (length==0) */
438 switch (Flags
& (ACPI_RESOURCE_FLAG_MIF
| ACPI_RESOURCE_FLAG_MAF
))
442 * Both _MIN and _MAX are variable.
443 * No additional requirements, just exit
447 case ACPI_RESOURCE_FLAG_MIF
:
449 /* _MIN is fixed. _MIN must be multiple of _GRA */
452 * The granularity is defined by the ACPI specification to be a
453 * power-of-two minus one, therefore the granularity is a
454 * bitmask which can be used to easily validate the addresses.
456 if (Granularity
& Minimum
)
458 AslError (ASL_ERROR
, ASL_MSG_ALIGNMENT
, MinOp
, NULL
);
462 case ACPI_RESOURCE_FLAG_MAF
:
464 /* _MAX is fixed. (_MAX + 1) must be multiple of _GRA */
466 if (Granularity
& (Maximum
+ 1))
468 AslError (ASL_ERROR
, ASL_MSG_ALIGNMENT
, MaxOp
, "-1");
472 /* Both MIF/MAF set is invalid if length is zero */
474 case (ACPI_RESOURCE_FLAG_MIF
| ACPI_RESOURCE_FLAG_MAF
):
477 AslError (ASL_ERROR
, ASL_MSG_INVALID_ADDR_FLAGS
, LengthOp
, NULL
);
483 /*******************************************************************************
485 * FUNCTION: RsGetStringDataLength
487 * PARAMETERS: InitializerOp - Start of a subtree of init nodes
489 * RETURN: Valid string length if a string node is found (otherwise 0)
491 * DESCRIPTION: In a list of peer nodes, find the first one that contains a
492 * string and return the length of the string.
494 ******************************************************************************/
497 RsGetStringDataLength (
498 ACPI_PARSE_OBJECT
*InitializerOp
)
501 while (InitializerOp
)
503 if (InitializerOp
->Asl
.ParseOpcode
== PARSEOP_STRING_LITERAL
)
505 return ((UINT16
) (strlen (InitializerOp
->Asl
.Value
.String
) + 1));
508 InitializerOp
= ASL_GET_PEER_NODE (InitializerOp
);
515 /*******************************************************************************
517 * FUNCTION: RsAllocateResourceNode
519 * PARAMETERS: Size - Size of node in bytes
521 * RETURN: The allocated node - aborts on allocation failure
523 * DESCRIPTION: Allocate a resource description node and the resource
524 * descriptor itself (the nodes are used to link descriptors).
526 ******************************************************************************/
529 RsAllocateResourceNode (
532 ASL_RESOURCE_NODE
*Rnode
;
535 /* Allocate the node */
537 Rnode
= UtLocalCalloc (sizeof (ASL_RESOURCE_NODE
));
539 /* Allocate the resource descriptor itself */
541 Rnode
->Buffer
= UtLocalCalloc (Size
);
542 Rnode
->BufferLength
= Size
;
547 /*******************************************************************************
549 * FUNCTION: RsCreateResourceField
551 * PARAMETERS: Op - Resource field node
552 * Name - Name of the field (Used only to reference
553 * the field in the ASL, not in the AML)
554 * ByteOffset - Offset from the field start
555 * BitOffset - Additional bit offset
556 * BitLength - Number of bits in the field
558 * RETURN: None, sets fields within the input node
560 * DESCRIPTION: Utility function to generate a named bit field within a
561 * resource descriptor. Mark a node as 1) a field in a resource
562 * descriptor, and 2) set the value to be a BIT offset
564 ******************************************************************************/
567 RsCreateResourceField (
568 ACPI_PARSE_OBJECT
*Op
,
575 Op
->Asl
.ExternalName
= Name
;
576 Op
->Asl
.CompileFlags
|= OP_IS_RESOURCE_FIELD
;
578 Op
->Asl
.Value
.Tag
.BitOffset
= (ByteOffset
* 8) + BitOffset
;
579 Op
->Asl
.Value
.Tag
.BitLength
= BitLength
;
583 /*******************************************************************************
585 * FUNCTION: RsSetFlagBits
587 * PARAMETERS: *Flags - Pointer to the flag byte
588 * Op - Flag initialization node
589 * Position - Bit position within the flag byte
590 * Default - Used if the node is DEFAULT.
592 * RETURN: Sets bits within the *Flags output byte.
594 * DESCRIPTION: Set a bit in a cumulative flags word from an initialization
595 * node. Will use a default value if the node is DEFAULT, meaning
596 * that no value was specified in the ASL. Used to merge multiple
597 * keywords into a single flags byte.
599 ******************************************************************************/
604 ACPI_PARSE_OBJECT
*Op
,
609 if (Op
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
)
611 /* Use the default bit */
613 *Flags
|= (DefaultBit
<< Position
);
617 /* Use the bit specified in the initialization node */
619 *Flags
|= (((UINT8
) Op
->Asl
.Value
.Integer
) << Position
);
627 ACPI_PARSE_OBJECT
*Op
,
632 if (Op
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
)
634 /* Use the default bit */
636 *Flags
|= (DefaultBit
<< Position
);
640 /* Use the bit specified in the initialization node */
642 *Flags
|= (((UINT16
) Op
->Asl
.Value
.Integer
) << Position
);
647 /*******************************************************************************
649 * FUNCTION: RsCompleteNodeAndGetNext
651 * PARAMETERS: Op - Resource node to be completed
653 * RETURN: The next peer to the input node.
655 * DESCRIPTION: Mark the current node completed and return the next peer.
656 * The node ParseOpcode is set to DEFAULT_ARG, meaning that
657 * this node is to be ignored from now on.
659 ******************************************************************************/
662 RsCompleteNodeAndGetNext (
663 ACPI_PARSE_OBJECT
*Op
)
666 /* Mark this node unused */
668 Op
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
670 /* Move on to the next peer node in the initializer list */
672 return (ASL_GET_PEER_NODE (Op
));
676 /*******************************************************************************
678 * FUNCTION: RsCheckListForDuplicates
680 * PARAMETERS: Op - First op in the initializer list
684 * DESCRIPTION: Check an initializer list for duplicate values. Emits an error
685 * if any duplicates are found.
687 ******************************************************************************/
690 RsCheckListForDuplicates (
691 ACPI_PARSE_OBJECT
*Op
)
693 ACPI_PARSE_OBJECT
*NextValueOp
= Op
;
694 ACPI_PARSE_OBJECT
*NextOp
;
703 /* Search list once for each value in the list */
707 Value
= (UINT32
) NextValueOp
->Asl
.Value
.Integer
;
709 /* Compare this value to all remaining values in the list */
711 NextOp
= ASL_GET_PEER_NODE (NextValueOp
);
714 if (NextOp
->Asl
.ParseOpcode
!= PARSEOP_DEFAULT_ARG
)
718 if (Value
== (UINT32
) NextOp
->Asl
.Value
.Integer
)
720 /* Emit error only once per duplicate node */
722 if (!(NextOp
->Asl
.CompileFlags
& OP_IS_DUPLICATE
))
724 NextOp
->Asl
.CompileFlags
|= OP_IS_DUPLICATE
;
725 AslError (ASL_ERROR
, ASL_MSG_DUPLICATE_ITEM
,
731 NextOp
= ASL_GET_PEER_NODE (NextOp
);
734 NextValueOp
= ASL_GET_PEER_NODE (NextValueOp
);
739 /*******************************************************************************
741 * FUNCTION: RsDoOneResourceDescriptor
743 * PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor
744 * CurrentByteOffset - Offset in the resource descriptor
747 * RETURN: A valid resource node for the descriptor
749 * DESCRIPTION: Dispatches the processing of one resource descriptor
751 ******************************************************************************/
754 RsDoOneResourceDescriptor (
755 ASL_RESOURCE_INFO
*Info
,
758 ASL_RESOURCE_NODE
*Rnode
= NULL
;
761 /* Construct the resource */
763 switch (Info
->DescriptorTypeOp
->Asl
.ParseOpcode
)
767 Rnode
= RsDoDmaDescriptor (Info
);
770 case PARSEOP_FIXEDDMA
:
772 Rnode
= RsDoFixedDmaDescriptor (Info
);
775 case PARSEOP_DWORDIO
:
777 Rnode
= RsDoDwordIoDescriptor (Info
);
780 case PARSEOP_DWORDMEMORY
:
782 Rnode
= RsDoDwordMemoryDescriptor (Info
);
785 case PARSEOP_DWORDSPACE
:
787 Rnode
= RsDoDwordSpaceDescriptor (Info
);
790 case PARSEOP_ENDDEPENDENTFN
:
794 case ACPI_RSTATE_NORMAL
:
796 AslError (ASL_ERROR
, ASL_MSG_MISSING_STARTDEPENDENT
,
797 Info
->DescriptorTypeOp
, NULL
);
800 case ACPI_RSTATE_START_DEPENDENT
:
802 AslError (ASL_ERROR
, ASL_MSG_DEPENDENT_NESTING
,
803 Info
->DescriptorTypeOp
, NULL
);
806 case ACPI_RSTATE_DEPENDENT_LIST
:
812 *State
= ACPI_RSTATE_NORMAL
;
813 Rnode
= RsDoEndDependentDescriptor (Info
);
818 Rnode
= RsDoEndTagDescriptor (Info
);
821 case PARSEOP_EXTENDEDIO
:
823 Rnode
= RsDoExtendedIoDescriptor (Info
);
826 case PARSEOP_EXTENDEDMEMORY
:
828 Rnode
= RsDoExtendedMemoryDescriptor (Info
);
831 case PARSEOP_EXTENDEDSPACE
:
833 Rnode
= RsDoExtendedSpaceDescriptor (Info
);
836 case PARSEOP_FIXEDIO
:
838 Rnode
= RsDoFixedIoDescriptor (Info
);
841 case PARSEOP_INTERRUPT
:
843 Rnode
= RsDoInterruptDescriptor (Info
);
848 Rnode
= RsDoIoDescriptor (Info
);
853 Rnode
= RsDoIrqDescriptor (Info
);
856 case PARSEOP_IRQNOFLAGS
:
858 Rnode
= RsDoIrqNoFlagsDescriptor (Info
);
861 case PARSEOP_MEMORY24
:
863 Rnode
= RsDoMemory24Descriptor (Info
);
866 case PARSEOP_MEMORY32
:
868 Rnode
= RsDoMemory32Descriptor (Info
);
871 case PARSEOP_MEMORY32FIXED
:
873 Rnode
= RsDoMemory32FixedDescriptor (Info
);
876 case PARSEOP_QWORDIO
:
878 Rnode
= RsDoQwordIoDescriptor (Info
);
881 case PARSEOP_QWORDMEMORY
:
883 Rnode
= RsDoQwordMemoryDescriptor (Info
);
886 case PARSEOP_QWORDSPACE
:
888 Rnode
= RsDoQwordSpaceDescriptor (Info
);
891 case PARSEOP_REGISTER
:
893 Rnode
= RsDoGeneralRegisterDescriptor (Info
);
896 case PARSEOP_STARTDEPENDENTFN
:
900 case ACPI_RSTATE_START_DEPENDENT
:
902 AslError (ASL_ERROR
, ASL_MSG_DEPENDENT_NESTING
,
903 Info
->DescriptorTypeOp
, NULL
);
906 case ACPI_RSTATE_NORMAL
:
907 case ACPI_RSTATE_DEPENDENT_LIST
:
913 *State
= ACPI_RSTATE_START_DEPENDENT
;
914 Rnode
= RsDoStartDependentDescriptor (Info
);
915 *State
= ACPI_RSTATE_DEPENDENT_LIST
;
918 case PARSEOP_STARTDEPENDENTFN_NOPRI
:
922 case ACPI_RSTATE_START_DEPENDENT
:
924 AslError (ASL_ERROR
, ASL_MSG_DEPENDENT_NESTING
,
925 Info
->DescriptorTypeOp
, NULL
);
928 case ACPI_RSTATE_NORMAL
:
929 case ACPI_RSTATE_DEPENDENT_LIST
:
935 *State
= ACPI_RSTATE_START_DEPENDENT
;
936 Rnode
= RsDoStartDependentNoPriDescriptor (Info
);
937 *State
= ACPI_RSTATE_DEPENDENT_LIST
;
940 case PARSEOP_VENDORLONG
:
942 Rnode
= RsDoVendorLargeDescriptor (Info
);
945 case PARSEOP_VENDORSHORT
:
947 Rnode
= RsDoVendorSmallDescriptor (Info
);
950 case PARSEOP_WORDBUSNUMBER
:
952 Rnode
= RsDoWordBusNumberDescriptor (Info
);
957 Rnode
= RsDoWordIoDescriptor (Info
);
960 case PARSEOP_WORDSPACE
:
962 Rnode
= RsDoWordSpaceDescriptor (Info
);
965 case PARSEOP_GPIO_INT
:
967 Rnode
= RsDoGpioIntDescriptor (Info
);
970 case PARSEOP_GPIO_IO
:
972 Rnode
= RsDoGpioIoDescriptor (Info
);
975 case PARSEOP_I2C_SERIALBUS
:
976 case PARSEOP_I2C_SERIALBUS_V2
:
978 Rnode
= RsDoI2cSerialBusDescriptor (Info
);
981 case PARSEOP_SPI_SERIALBUS
:
982 case PARSEOP_SPI_SERIALBUS_V2
:
984 Rnode
= RsDoSpiSerialBusDescriptor (Info
);
987 case PARSEOP_UART_SERIALBUS
:
988 case PARSEOP_UART_SERIALBUS_V2
:
990 Rnode
= RsDoUartSerialBusDescriptor (Info
);
993 case PARSEOP_PINCONFIG
:
995 Rnode
= RsDoPinConfigDescriptor (Info
);
998 case PARSEOP_PINFUNCTION
:
1000 Rnode
= RsDoPinFunctionDescriptor (Info
);
1003 case PARSEOP_PINGROUP
:
1005 Rnode
= RsDoPinGroupDescriptor (Info
);
1008 case PARSEOP_PINGROUPFUNCTION
:
1010 Rnode
= RsDoPinGroupFunctionDescriptor (Info
);
1013 case PARSEOP_PINGROUPCONFIG
:
1015 Rnode
= RsDoPinGroupConfigDescriptor (Info
);
1018 case PARSEOP_DEFAULT_ARG
:
1020 /* Just ignore any of these, they are used as fillers/placeholders */
1025 printf ("Unknown resource descriptor type [%s]\n",
1026 Info
->DescriptorTypeOp
->Asl
.ParseOpName
);
1031 * Mark original node as unused, but head of a resource descriptor.
1032 * This allows the resource to be installed in the namespace so that
1033 * references to the descriptor can be resolved.
1035 Info
->DescriptorTypeOp
->Asl
.ParseOpcode
= PARSEOP_DEFAULT_ARG
;
1036 Info
->DescriptorTypeOp
->Asl
.CompileFlags
= OP_IS_RESOURCE_DESC
;
1037 Info
->DescriptorTypeOp
->Asl
.Value
.Integer
= Info
->CurrentByteOffset
;
1041 Info
->DescriptorTypeOp
->Asl
.FinalAmlLength
= Rnode
->BufferLength
;
1042 Info
->DescriptorTypeOp
->Asl
.Extra
=
1043 ((AML_RESOURCE
*) Rnode
->Buffer
)->DescriptorType
;
1050 /*******************************************************************************
1052 * FUNCTION: RsLinkDescriptorChain
1054 * PARAMETERS: PreviousRnode - Pointer to the node that will be previous
1055 * to the linked node, At exit, set to the
1056 * last node in the new chain.
1057 * Rnode - Resource node to link into the list
1059 * RETURN: Cumulative buffer byte offset of the new segment of chain
1061 * DESCRIPTION: Link a descriptor chain at the end of an existing chain.
1063 ******************************************************************************/
1066 RsLinkDescriptorChain (
1067 ASL_RESOURCE_NODE
**PreviousRnode
,
1068 ASL_RESOURCE_NODE
*Rnode
)
1070 ASL_RESOURCE_NODE
*LastRnode
;
1071 UINT32 CurrentByteOffset
;
1074 /* Anything to do? */
1081 /* Point the previous node to the new node */
1083 (*PreviousRnode
)->Next
= Rnode
;
1084 CurrentByteOffset
= Rnode
->BufferLength
;
1086 /* Walk to the end of the chain headed by Rnode */
1089 while (LastRnode
->Next
)
1091 LastRnode
= LastRnode
->Next
;
1092 CurrentByteOffset
+= LastRnode
->BufferLength
;
1095 /* Previous node becomes the last node in the chain */
1097 *PreviousRnode
= LastRnode
;
1098 return (CurrentByteOffset
);
1102 /*******************************************************************************
1104 * FUNCTION: RsDoResourceTemplate
1106 * PARAMETERS: Op - Parent of a resource template list
1108 * RETURN: None. Sets input node to point to a list of AML code
1110 * DESCRIPTION: Merge a list of resource descriptors into a single AML buffer,
1111 * in preparation for output to the AML output file.
1113 ******************************************************************************/
1116 RsDoResourceTemplate (
1117 ACPI_PARSE_OBJECT
*Op
)
1119 ACPI_PARSE_OBJECT
*BufferLengthOp
;
1120 ACPI_PARSE_OBJECT
*BufferOp
;
1121 ACPI_PARSE_OBJECT
*DescriptorTypeOp
;
1122 ACPI_PARSE_OBJECT
*LastOp
= NULL
;
1123 UINT32 CurrentByteOffset
= 0;
1124 ASL_RESOURCE_NODE HeadRnode
;
1125 ASL_RESOURCE_NODE
*PreviousRnode
;
1126 ASL_RESOURCE_NODE
*Rnode
;
1127 ASL_RESOURCE_INFO Info
;
1131 /* Mark parent as containing a resource template */
1135 Op
->Asl
.Parent
->Asl
.CompileFlags
|= OP_IS_RESOURCE_DESC
;
1138 /* ResourceTemplate Opcode is first (Op) */
1139 /* Buffer Length node is first child */
1141 BufferLengthOp
= ASL_GET_CHILD_NODE (Op
);
1143 /* Buffer Op is first peer */
1145 BufferOp
= ASL_GET_PEER_NODE (BufferLengthOp
);
1147 /* First Descriptor type is next */
1149 DescriptorTypeOp
= ASL_GET_PEER_NODE (BufferOp
);
1151 /* DEFAULT_ARG indicates null template - ResourceTemplate(){} */
1153 if (DescriptorTypeOp
->Asl
.ParseOpcode
== PARSEOP_DEFAULT_ARG
)
1155 AslError (ASL_WARNING
, ASL_MSG_NULL_RESOURCE_TEMPLATE
,
1156 DescriptorTypeOp
, DescriptorTypeOp
->Asl
.Value
.String
);
1160 * Process all resource descriptors in the list
1161 * Note: It is assumed that the EndTag node has been automatically
1162 * inserted at the end of the template by the parser.
1164 State
= ACPI_RSTATE_NORMAL
;
1165 PreviousRnode
= &HeadRnode
;
1166 while (DescriptorTypeOp
)
1168 /* Save information for optional mapfile */
1170 if (Op
->Asl
.Parent
->Asl
.ParseOpcode
== PARSEOP_CONNECTION
)
1172 Info
.MappingOp
= Op
->Asl
.Parent
;
1176 Info
.MappingOp
= DescriptorTypeOp
;
1179 Info
.DescriptorTypeOp
= DescriptorTypeOp
;
1180 Info
.CurrentByteOffset
= CurrentByteOffset
;
1182 DescriptorTypeOp
->Asl
.CompileFlags
|= OP_IS_RESOURCE_DESC
;
1183 Rnode
= RsDoOneResourceDescriptor (&Info
, &State
);
1186 * Update current byte offset to indicate the number of bytes from the
1187 * start of the buffer. Buffer can include multiple descriptors, we
1188 * must keep track of the offset of not only each descriptor, but each
1189 * element (field) within each descriptor as well.
1191 CurrentByteOffset
+= RsLinkDescriptorChain (&PreviousRnode
, Rnode
);
1193 /* Get the next descriptor in the list */
1195 LastOp
= DescriptorTypeOp
;
1196 DescriptorTypeOp
= ASL_GET_PEER_NODE (DescriptorTypeOp
);
1199 if (State
== ACPI_RSTATE_DEPENDENT_LIST
)
1203 LastOp
= LastOp
->Asl
.Parent
;
1205 AslError (ASL_ERROR
, ASL_MSG_MISSING_ENDDEPENDENT
, LastOp
, NULL
);
1209 * Transform the nodes into the following
1211 * Op -> AML_BUFFER_OP
1212 * First Child -> BufferLength
1213 * Second Child -> Descriptor Buffer (raw byte data)
1215 Op
->Asl
.ParseOpcode
= PARSEOP_BUFFER
;
1216 Op
->Asl
.AmlOpcode
= AML_BUFFER_OP
;
1217 Op
->Asl
.CompileFlags
= OP_AML_PACKAGE
| OP_IS_RESOURCE_DESC
;
1218 UtSetParseOpName (Op
);
1220 BufferLengthOp
->Asl
.ParseOpcode
= PARSEOP_INTEGER
;
1221 BufferLengthOp
->Asl
.Value
.Integer
= CurrentByteOffset
;
1222 (void) OpcSetOptimalIntegerSize (BufferLengthOp
);
1223 UtSetParseOpName (BufferLengthOp
);
1225 BufferOp
->Asl
.ParseOpcode
= PARSEOP_RAW_DATA
;
1226 BufferOp
->Asl
.AmlOpcode
= AML_RAW_DATA_CHAIN
;
1227 BufferOp
->Asl
.AmlOpcodeLength
= 0;
1228 BufferOp
->Asl
.AmlLength
= CurrentByteOffset
;
1229 BufferOp
->Asl
.Value
.Buffer
= (UINT8
*) HeadRnode
.Next
;
1230 BufferOp
->Asl
.CompileFlags
|= OP_IS_RESOURCE_DATA
;
1231 UtSetParseOpName (BufferOp
);