2 /******************************************************************************
4 * Module Name: aslrestype1 - Miscellaneous small resource descriptors
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"
121 #define _COMPONENT ACPI_COMPILER
122 ACPI_MODULE_NAME ("aslrestype1")
125 * This module contains miscellaneous small resource descriptors:
133 * StartDependentFnNoPri
137 /*******************************************************************************
139 * FUNCTION: RsDoEndTagDescriptor
141 * PARAMETERS: Op - Parent resource descriptor parse node
142 * CurrentByteOffset - Offset into the resource template AML
143 * buffer (to track references to the desc)
145 * RETURN: Completed resource node
147 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
149 ******************************************************************************/
152 RsDoEndTagDescriptor (
153 ACPI_PARSE_OBJECT *Op,
154 UINT32 CurrentByteOffset)
156 AML_RESOURCE *Descriptor;
157 ASL_RESOURCE_NODE *Rnode;
160 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG));
162 Descriptor = Rnode->Buffer;
163 Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG |
164 ASL_RDESC_END_TAG_SIZE;
165 Descriptor->EndTag.Checksum = 0;
171 /*******************************************************************************
173 * FUNCTION: RsDoEndDependentDescriptor
175 * PARAMETERS: Op - Parent resource descriptor parse node
176 * CurrentByteOffset - Offset into the resource template AML
177 * buffer (to track references to the desc)
179 * RETURN: Completed resource node
181 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
183 ******************************************************************************/
186 RsDoEndDependentDescriptor (
187 ACPI_PARSE_OBJECT *Op,
188 UINT32 CurrentByteOffset)
190 AML_RESOURCE *Descriptor;
191 ASL_RESOURCE_NODE *Rnode;
194 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
196 Descriptor = Rnode->Buffer;
197 Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT |
198 ASL_RDESC_END_DEPEND_SIZE;
203 /*******************************************************************************
205 * FUNCTION: RsDoMemory24Descriptor
207 * PARAMETERS: Op - Parent resource descriptor parse node
208 * CurrentByteOffset - Offset into the resource template AML
209 * buffer (to track references to the desc)
211 * RETURN: Completed resource node
213 * DESCRIPTION: Construct a short "Memory24" descriptor
215 ******************************************************************************/
218 RsDoMemory24Descriptor (
219 ACPI_PARSE_OBJECT *Op,
220 UINT32 CurrentByteOffset)
222 AML_RESOURCE *Descriptor;
223 ACPI_PARSE_OBJECT *InitializerOp;
224 ACPI_PARSE_OBJECT *MinOp = NULL;
225 ACPI_PARSE_OBJECT *MaxOp = NULL;
226 ACPI_PARSE_OBJECT *LengthOp = NULL;
227 ASL_RESOURCE_NODE *Rnode;
231 InitializerOp = Op->Asl.Child;
232 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
234 Descriptor = Rnode->Buffer;
235 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
236 Descriptor->Memory24.ResourceLength = 9;
238 /* Process all child initialization nodes */
240 for (i = 0; InitializerOp; i++)
244 case 0: /* Read/Write type */
246 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
247 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
248 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
251 case 1: /* Min Address */
253 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
254 RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
255 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
256 MinOp = InitializerOp;
259 case 2: /* Max Address */
261 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
262 RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
263 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
264 MaxOp = InitializerOp;
267 case 3: /* Alignment */
269 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
270 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
271 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
276 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
277 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
278 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
279 LengthOp = InitializerOp;
284 UtAttachNamepathToOwner (Op, InitializerOp);
289 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
293 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
296 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
298 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
299 Descriptor->Memory24.Minimum,
300 Descriptor->Memory24.Maximum,
301 Descriptor->Memory24.AddressLength,
302 Descriptor->Memory24.Alignment,
303 MinOp, MaxOp, LengthOp, NULL, Op);
309 /*******************************************************************************
311 * FUNCTION: RsDoMemory32Descriptor
313 * PARAMETERS: Op - Parent resource descriptor parse node
314 * CurrentByteOffset - Offset into the resource template AML
315 * buffer (to track references to the desc)
317 * RETURN: Completed resource node
319 * DESCRIPTION: Construct a short "Memory32" descriptor
321 ******************************************************************************/
324 RsDoMemory32Descriptor (
325 ACPI_PARSE_OBJECT *Op,
326 UINT32 CurrentByteOffset)
328 AML_RESOURCE *Descriptor;
329 ACPI_PARSE_OBJECT *InitializerOp;
330 ACPI_PARSE_OBJECT *MinOp = NULL;
331 ACPI_PARSE_OBJECT *MaxOp = NULL;
332 ACPI_PARSE_OBJECT *LengthOp = NULL;
333 ACPI_PARSE_OBJECT *AlignOp = NULL;
334 ASL_RESOURCE_NODE *Rnode;
338 InitializerOp = Op->Asl.Child;
339 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
341 Descriptor = Rnode->Buffer;
342 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
343 Descriptor->Memory32.ResourceLength = 17;
345 /* Process all child initialization nodes */
347 for (i = 0; InitializerOp; i++)
351 case 0: /* Read/Write type */
353 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
354 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
355 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
358 case 1: /* Min Address */
360 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
361 RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
362 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
363 MinOp = InitializerOp;
366 case 2: /* Max Address */
368 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
369 RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
370 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
371 MaxOp = InitializerOp;
374 case 3: /* Alignment */
376 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
377 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
378 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
379 AlignOp = InitializerOp;
384 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
385 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
386 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
387 LengthOp = InitializerOp;
392 UtAttachNamepathToOwner (Op, InitializerOp);
397 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
401 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
404 /* Validate the Min/Max/Len/Align values */
406 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
407 Descriptor->Memory32.Minimum,
408 Descriptor->Memory32.Maximum,
409 Descriptor->Memory32.AddressLength,
410 Descriptor->Memory32.Alignment,
411 MinOp, MaxOp, LengthOp, AlignOp, Op);
417 /*******************************************************************************
419 * FUNCTION: RsDoMemory32FixedDescriptor
421 * PARAMETERS: Op - Parent resource descriptor parse node
422 * CurrentByteOffset - Offset into the resource template AML
423 * buffer (to track references to the desc)
425 * RETURN: Completed resource node
427 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
429 ******************************************************************************/
432 RsDoMemory32FixedDescriptor (
433 ACPI_PARSE_OBJECT *Op,
434 UINT32 CurrentByteOffset)
436 AML_RESOURCE *Descriptor;
437 ACPI_PARSE_OBJECT *InitializerOp;
438 ASL_RESOURCE_NODE *Rnode;
442 InitializerOp = Op->Asl.Child;
443 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
445 Descriptor = Rnode->Buffer;
446 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
447 Descriptor->FixedMemory32.ResourceLength = 9;
449 /* Process all child initialization nodes */
451 for (i = 0; InitializerOp; i++)
455 case 0: /* Read/Write type */
457 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
458 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
459 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
462 case 1: /* Address */
464 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
465 RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
466 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
471 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
472 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
473 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
478 UtAttachNamepathToOwner (Op, InitializerOp);
483 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
487 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
494 /*******************************************************************************
496 * FUNCTION: RsDoStartDependentDescriptor
498 * PARAMETERS: Op - Parent resource descriptor parse node
499 * CurrentByteOffset - Offset into the resource template AML
500 * buffer (to track references to the desc)
502 * RETURN: Completed resource node
504 * DESCRIPTION: Construct a short "StartDependentFn" descriptor
506 ******************************************************************************/
509 RsDoStartDependentDescriptor (
510 ACPI_PARSE_OBJECT *Op,
511 UINT32 CurrentByteOffset)
513 AML_RESOURCE *Descriptor;
514 ACPI_PARSE_OBJECT *InitializerOp;
515 ASL_RESOURCE_NODE *Rnode;
516 ASL_RESOURCE_NODE *PreviousRnode;
517 ASL_RESOURCE_NODE *NextRnode;
522 InitializerOp = Op->Asl.Child;
523 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
525 PreviousRnode = Rnode;
526 Descriptor = Rnode->Buffer;
528 /* Descriptor has priority byte */
530 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
531 (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
533 /* Process all child initialization nodes */
535 State = ACPI_RSTATE_START_DEPENDENT;
536 for (i = 0; InitializerOp; i++)
540 case 0: /* Compatibility Priority */
542 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
544 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
545 InitializerOp, NULL);
548 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
551 case 1: /* Performance/Robustness Priority */
553 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
555 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
556 InitializerOp, NULL);
559 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
564 NextRnode = RsDoOneResourceDescriptor (InitializerOp,
565 CurrentByteOffset, &State);
568 * Update current byte offset to indicate the number of bytes from the
569 * start of the buffer. Buffer can include multiple descriptors, we
570 * must keep track of the offset of not only each descriptor, but each
571 * element (field) within each descriptor as well.
573 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode,
578 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
585 /*******************************************************************************
587 * FUNCTION: RsDoStartDependentNoPriDescriptor
589 * PARAMETERS: Op - Parent resource descriptor parse node
590 * CurrentByteOffset - Offset into the resource template AML
591 * buffer (to track references to the desc)
593 * RETURN: Completed resource node
595 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
597 ******************************************************************************/
600 RsDoStartDependentNoPriDescriptor (
601 ACPI_PARSE_OBJECT *Op,
602 UINT32 CurrentByteOffset)
604 AML_RESOURCE *Descriptor;
605 ACPI_PARSE_OBJECT *InitializerOp;
606 ASL_RESOURCE_NODE *Rnode;
607 ASL_RESOURCE_NODE *PreviousRnode;
608 ASL_RESOURCE_NODE *NextRnode;
612 InitializerOp = Op->Asl.Child;
613 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
615 Descriptor = Rnode->Buffer;
616 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
617 ASL_RDESC_ST_DEPEND_SIZE;
618 PreviousRnode = Rnode;
620 /* Process all child initialization nodes */
622 State = ACPI_RSTATE_START_DEPENDENT;
623 while (InitializerOp)
625 NextRnode = RsDoOneResourceDescriptor (InitializerOp,
626 CurrentByteOffset, &State);
629 * Update current byte offset to indicate the number of bytes from the
630 * start of the buffer. Buffer can include multiple descriptors, we
631 * must keep track of the offset of not only each descriptor, but each
632 * element (field) within each descriptor as well.
634 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
636 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
643 /*******************************************************************************
645 * FUNCTION: RsDoVendorSmallDescriptor
647 * PARAMETERS: Op - Parent resource descriptor parse node
648 * CurrentByteOffset - Offset into the resource template AML
649 * buffer (to track references to the desc)
651 * RETURN: Completed resource node
653 * DESCRIPTION: Construct a short "VendorShort" descriptor
655 ******************************************************************************/
658 RsDoVendorSmallDescriptor (
659 ACPI_PARSE_OBJECT *Op,
660 UINT32 CurrentByteOffset)
662 AML_RESOURCE *Descriptor;
663 ACPI_PARSE_OBJECT *InitializerOp;
664 ASL_RESOURCE_NODE *Rnode;
669 InitializerOp = Op->Asl.Child;
671 /* Allocate worst case - 7 vendor bytes */
673 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
675 Descriptor = Rnode->Buffer;
676 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL;
677 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
679 /* Process all child initialization nodes */
681 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
682 for (i = 0; InitializerOp; i++)
684 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
689 /* Maximum 7 vendor data bytes allowed (0-6) */
693 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
695 /* Eat the excess initializers */
697 while (InitializerOp)
699 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
704 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
705 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
708 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
710 Rnode->BufferLength -= (7 - i);
712 /* Set the length in the Type Tag */
714 Descriptor->VendorSmall.DescriptorType |= (UINT8) i;