2 /******************************************************************************
4 * Module Name: aslrestype1i - Small I/O-related 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 ("aslrestype1i")
125 * This module contains the I/O-related small resource descriptors:
134 /*******************************************************************************
136 * FUNCTION: RsDoDmaDescriptor
138 * PARAMETERS: Op - Parent resource descriptor parse node
139 * CurrentByteOffset - Offset into the resource template AML
140 * buffer (to track references to the desc)
142 * RETURN: Completed resource node
144 * DESCRIPTION: Construct a short "DMA" descriptor
146 ******************************************************************************/
150 ACPI_PARSE_OBJECT *Op,
151 UINT32 CurrentByteOffset)
153 AML_RESOURCE *Descriptor;
154 ACPI_PARSE_OBJECT *InitializerOp;
155 ASL_RESOURCE_NODE *Rnode;
157 UINT8 DmaChannelMask = 0;
158 UINT8 DmaChannels = 0;
161 InitializerOp = Op->Asl.Child;
162 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA));
164 Descriptor = Rnode->Buffer;
165 Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA |
168 /* Process all child initialization nodes */
170 for (i = 0; InitializerOp; i++)
174 case 0: /* DMA type */
176 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
177 RsCreateBitField (InitializerOp, ACPI_RESTAG_DMATYPE,
178 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5);
181 case 1: /* Bus Master */
183 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
184 RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER,
185 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
188 case 2: /* Xfer Type (transfer width) */
190 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
191 RsCreateBitField (InitializerOp, ACPI_RESTAG_XFERTYPE,
192 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0);
197 UtAttachNamepathToOwner (Op, InitializerOp);
202 /* All DMA channel bytes are handled here, after flags and name */
204 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
206 /* Up to 8 channels can be specified in the list */
211 AslError (ASL_ERROR, ASL_MSG_DMA_LIST,
212 InitializerOp, NULL);
216 /* Only DMA channels 0-7 are allowed (mask is 8 bits) */
218 if (InitializerOp->Asl.Value.Integer > 7)
220 AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL,
221 InitializerOp, NULL);
227 (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
230 if (i == 4) /* case 4: First DMA byte */
232 /* Check now for duplicates in list */
234 RsCheckListForDuplicates (InitializerOp);
236 /* Create a named field at the start of the list */
238 RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA,
240 ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
245 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
248 /* Now we can set the channel mask */
250 Descriptor->Dma.DmaChannelMask = DmaChannelMask;
255 /*******************************************************************************
257 * FUNCTION: RsDoFixedIoDescriptor
259 * PARAMETERS: Op - Parent resource descriptor parse node
260 * CurrentByteOffset - Offset into the resource template AML
261 * buffer (to track references to the desc)
263 * RETURN: Completed resource node
265 * DESCRIPTION: Construct a short "FixedIO" descriptor
267 ******************************************************************************/
270 RsDoFixedIoDescriptor (
271 ACPI_PARSE_OBJECT *Op,
272 UINT32 CurrentByteOffset)
274 AML_RESOURCE *Descriptor;
275 ACPI_PARSE_OBJECT *InitializerOp;
276 ACPI_PARSE_OBJECT *AddressOp = NULL;
277 ASL_RESOURCE_NODE *Rnode;
281 InitializerOp = Op->Asl.Child;
282 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO));
284 Descriptor = Rnode->Buffer;
285 Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO |
286 ASL_RDESC_FIXED_IO_SIZE;
288 /* Process all child initialization nodes */
290 for (i = 0; InitializerOp; i++)
294 case 0: /* Base Address */
296 Descriptor->FixedIo.Address =
297 (UINT16) InitializerOp->Asl.Value.Integer;
298 RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
299 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
300 AddressOp = InitializerOp;
305 Descriptor->FixedIo.AddressLength =
306 (UINT8) InitializerOp->Asl.Value.Integer;
307 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
308 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength));
313 UtAttachNamepathToOwner (Op, InitializerOp);
318 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
322 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
327 if (Descriptor->FixedIo.Address > 0x03FF)
329 AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
336 /*******************************************************************************
338 * FUNCTION: RsDoIoDescriptor
340 * PARAMETERS: Op - Parent resource descriptor parse node
341 * CurrentByteOffset - Offset into the resource template AML
342 * buffer (to track references to the desc)
344 * RETURN: Completed resource node
346 * DESCRIPTION: Construct a short "IO" descriptor
348 ******************************************************************************/
352 ACPI_PARSE_OBJECT *Op,
353 UINT32 CurrentByteOffset)
355 AML_RESOURCE *Descriptor;
356 ACPI_PARSE_OBJECT *InitializerOp;
357 ACPI_PARSE_OBJECT *MinOp = NULL;
358 ACPI_PARSE_OBJECT *MaxOp = NULL;
359 ACPI_PARSE_OBJECT *LengthOp = NULL;
360 ACPI_PARSE_OBJECT *AlignOp = NULL;
361 ASL_RESOURCE_NODE *Rnode;
365 InitializerOp = Op->Asl.Child;
366 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO));
368 Descriptor = Rnode->Buffer;
369 Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO |
372 /* Process all child initialization nodes */
374 for (i = 0; InitializerOp; i++)
378 case 0: /* Decode size */
380 RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1);
381 RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
382 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0);
385 case 1: /* Min Address */
387 Descriptor->Io.Minimum =
388 (UINT16) InitializerOp->Asl.Value.Integer;
389 RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
390 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
391 MinOp = InitializerOp;
394 case 2: /* Max Address */
396 Descriptor->Io.Maximum =
397 (UINT16) InitializerOp->Asl.Value.Integer;
398 RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
399 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
400 MaxOp = InitializerOp;
403 case 3: /* Alignment */
405 Descriptor->Io.Alignment =
406 (UINT8) InitializerOp->Asl.Value.Integer;
407 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
408 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment));
409 AlignOp = InitializerOp;
414 Descriptor->Io.AddressLength =
415 (UINT8) InitializerOp->Asl.Value.Integer;
416 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
417 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength));
418 LengthOp = InitializerOp;
423 UtAttachNamepathToOwner (Op, InitializerOp);
428 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
432 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
435 /* Validate the Min/Max/Len/Align values */
437 RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
438 Descriptor->Io.Minimum,
439 Descriptor->Io.Maximum,
440 Descriptor->Io.AddressLength,
441 Descriptor->Io.Alignment,
442 MinOp, MaxOp, LengthOp, AlignOp, Op);
448 /*******************************************************************************
450 * FUNCTION: RsDoIrqDescriptor
452 * PARAMETERS: Op - Parent resource descriptor parse node
453 * CurrentByteOffset - Offset into the resource template AML
454 * buffer (to track references to the desc)
456 * RETURN: Completed resource node
458 * DESCRIPTION: Construct a short "IRQ" descriptor
460 ******************************************************************************/
464 ACPI_PARSE_OBJECT *Op,
465 UINT32 CurrentByteOffset)
467 AML_RESOURCE *Descriptor;
468 ACPI_PARSE_OBJECT *InitializerOp;
469 ASL_RESOURCE_NODE *Rnode;
470 UINT32 Interrupts = 0;
475 InitializerOp = Op->Asl.Child;
476 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ));
478 /* Length = 3 (with flag byte) */
480 Descriptor = Rnode->Buffer;
481 Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ |
482 (ASL_RDESC_IRQ_SIZE + 0x01);
484 /* Process all child initialization nodes */
486 for (i = 0; InitializerOp; i++)
490 case 0: /* Interrupt Type (or Mode - edge/level) */
492 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
493 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
494 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
497 case 1: /* Interrupt Level (or Polarity - Active high/low) */
499 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
500 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
501 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
504 case 2: /* Share Type - Default: exclusive (0) */
506 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
507 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
508 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
513 UtAttachNamepathToOwner (Op, InitializerOp);
518 /* All IRQ bytes are handled here, after the flags and name */
520 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
522 /* Up to 16 interrupts can be specified in the list */
527 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
528 InitializerOp, NULL);
532 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
534 if (InitializerOp->Asl.Value.Integer > 15)
536 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
537 InitializerOp, NULL);
541 IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
545 /* Case 4: First IRQ value in list */
549 /* Check now for duplicates in list */
551 RsCheckListForDuplicates (InitializerOp);
553 /* Create a named field at the start of the list */
555 RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT,
556 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
561 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
564 /* Now we can set the channel mask */
566 Descriptor->Irq.IrqMask = IrqMask;
571 /*******************************************************************************
573 * FUNCTION: RsDoIrqNoFlagsDescriptor
575 * PARAMETERS: Op - Parent resource descriptor parse node
576 * CurrentByteOffset - Offset into the resource template AML
577 * buffer (to track references to the desc)
579 * RETURN: Completed resource node
581 * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
583 ******************************************************************************/
586 RsDoIrqNoFlagsDescriptor (
587 ACPI_PARSE_OBJECT *Op,
588 UINT32 CurrentByteOffset)
590 AML_RESOURCE *Descriptor;
591 ACPI_PARSE_OBJECT *InitializerOp;
592 ASL_RESOURCE_NODE *Rnode;
594 UINT32 Interrupts = 0;
598 InitializerOp = Op->Asl.Child;
599 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS));
601 Descriptor = Rnode->Buffer;
602 Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ |
605 /* Process all child initialization nodes */
607 for (i = 0; InitializerOp; i++)
613 UtAttachNamepathToOwner (Op, InitializerOp);
618 /* IRQ bytes are handled here, after the flags and name */
620 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
622 /* Up to 16 interrupts can be specified in the list */
627 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
628 InitializerOp, NULL);
632 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
634 if (InitializerOp->Asl.Value.Integer > 15)
636 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
637 InitializerOp, NULL);
641 IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
645 /* Case 1: First IRQ value in list */
649 /* Check now for duplicates in list */
651 RsCheckListForDuplicates (InitializerOp);
653 /* Create a named field at the start of the list */
655 RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT,
656 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
661 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
664 /* Now we can set the interrupt mask */
666 Descriptor->Irq.IrqMask = IrqMask;