1 /******************************************************************************
3 * Module Name: aslrestype1i - Small I/O-related resource descriptors
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, 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 #include "aslcompiler.h"
117 #include "aslcompiler.y.h"
119 #define _COMPONENT ACPI_COMPILER
120 ACPI_MODULE_NAME ("aslrestype1i")
123 * This module contains the I/O-related small resource descriptors:
133 /*******************************************************************************
135 * FUNCTION: RsDoDmaDescriptor
137 * PARAMETERS: Info - Parse Op and resource template offset
139 * RETURN: Completed resource node
141 * DESCRIPTION: Construct a short "DMA" descriptor
143 ******************************************************************************/
147 ASL_RESOURCE_INFO *Info)
149 AML_RESOURCE *Descriptor;
150 ACPI_PARSE_OBJECT *InitializerOp;
151 ASL_RESOURCE_NODE *Rnode;
152 UINT32 CurrentByteOffset;
154 UINT8 DmaChannelMask = 0;
155 UINT8 DmaChannels = 0;
158 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
159 CurrentByteOffset = Info->CurrentByteOffset;
160 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA));
162 Descriptor = Rnode->Buffer;
163 Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA |
166 /* Process all child initialization nodes */
168 for (i = 0; InitializerOp; i++)
172 case 0: /* DMA type */
174 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
175 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_DMATYPE,
176 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5, 2);
179 case 1: /* Bus Master */
181 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
182 RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER,
183 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
186 case 2: /* Xfer Type (transfer width) */
188 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
189 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_XFERTYPE,
190 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0, 2);
195 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
200 /* All DMA channel bytes are handled here, after flags and name */
202 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
204 /* Up to 8 channels can be specified in the list */
209 AslError (ASL_ERROR, ASL_MSG_DMA_LIST,
210 InitializerOp, NULL);
214 /* Only DMA channels 0-7 are allowed (mask is 8 bits) */
216 if (InitializerOp->Asl.Value.Integer > 7)
218 AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL,
219 InitializerOp, NULL);
225 (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
228 if (i == 4) /* case 4: First DMA byte */
230 /* Check now for duplicates in list */
232 RsCheckListForDuplicates (InitializerOp);
234 /* Create a named field at the start of the list */
236 RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA,
238 ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
243 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
246 /* Now we can set the channel mask */
248 Descriptor->Dma.DmaChannelMask = DmaChannelMask;
253 /*******************************************************************************
255 * FUNCTION: RsDoFixedDmaDescriptor
257 * PARAMETERS: Info - Parse Op and resource template offset
259 * RETURN: Completed resource node
261 * DESCRIPTION: Construct a short "FixedDMA" descriptor
263 ******************************************************************************/
266 RsDoFixedDmaDescriptor (
267 ASL_RESOURCE_INFO *Info)
269 AML_RESOURCE *Descriptor;
270 ACPI_PARSE_OBJECT *InitializerOp;
271 ASL_RESOURCE_NODE *Rnode;
272 UINT32 CurrentByteOffset;
276 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
277 CurrentByteOffset = Info->CurrentByteOffset;
278 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_DMA));
280 Descriptor = Rnode->Buffer;
281 Descriptor->FixedDma.DescriptorType =
282 ACPI_RESOURCE_NAME_FIXED_DMA | ASL_RDESC_FIXED_DMA_SIZE;
284 /* Process all child initialization nodes */
286 for (i = 0; InitializerOp; i++)
290 case 0: /* DMA Request Lines [WORD] (_DMA) */
292 Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
293 RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
294 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
297 case 1: /* DMA Channel [WORD] (_TYP) */
299 Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
300 RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
301 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
304 case 2: /* Transfer Width [BYTE] (_SIZ) */
306 Descriptor->FixedDma.Width = (UINT8) InitializerOp->Asl.Value.Integer;
307 RsCreateByteField (InitializerOp, ACPI_RESTAG_XFERTYPE,
308 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Width));
311 case 3: /* Descriptor Name (optional) */
313 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
316 default: /* Ignore any extra nodes */
321 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
328 /*******************************************************************************
330 * FUNCTION: RsDoFixedIoDescriptor
332 * PARAMETERS: Info - Parse Op and resource template offset
334 * RETURN: Completed resource node
336 * DESCRIPTION: Construct a short "FixedIO" descriptor
338 ******************************************************************************/
341 RsDoFixedIoDescriptor (
342 ASL_RESOURCE_INFO *Info)
344 AML_RESOURCE *Descriptor;
345 ACPI_PARSE_OBJECT *InitializerOp;
346 ACPI_PARSE_OBJECT *AddressOp = NULL;
347 ASL_RESOURCE_NODE *Rnode;
348 UINT32 CurrentByteOffset;
352 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
353 CurrentByteOffset = Info->CurrentByteOffset;
354 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO));
356 Descriptor = Rnode->Buffer;
357 Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO |
358 ASL_RDESC_FIXED_IO_SIZE;
360 /* Process all child initialization nodes */
362 for (i = 0; InitializerOp; i++)
366 case 0: /* Base Address */
368 Descriptor->FixedIo.Address =
369 (UINT16) InitializerOp->Asl.Value.Integer;
370 RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
371 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
372 AddressOp = InitializerOp;
377 Descriptor->FixedIo.AddressLength =
378 (UINT8) InitializerOp->Asl.Value.Integer;
379 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
380 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength));
385 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
390 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
394 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
399 if (Descriptor->FixedIo.Address > 0x03FF)
401 AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
408 /*******************************************************************************
410 * FUNCTION: RsDoIoDescriptor
412 * PARAMETERS: Info - Parse Op and resource template offset
414 * RETURN: Completed resource node
416 * DESCRIPTION: Construct a short "IO" descriptor
418 ******************************************************************************/
422 ASL_RESOURCE_INFO *Info)
424 AML_RESOURCE *Descriptor;
425 ACPI_PARSE_OBJECT *InitializerOp;
426 ACPI_PARSE_OBJECT *MinOp = NULL;
427 ACPI_PARSE_OBJECT *MaxOp = NULL;
428 ACPI_PARSE_OBJECT *LengthOp = NULL;
429 ACPI_PARSE_OBJECT *AlignOp = NULL;
430 ASL_RESOURCE_NODE *Rnode;
431 UINT32 CurrentByteOffset;
435 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
436 CurrentByteOffset = Info->CurrentByteOffset;
437 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO));
439 Descriptor = Rnode->Buffer;
440 Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO |
443 /* Process all child initialization nodes */
445 for (i = 0; InitializerOp; i++)
449 case 0: /* Decode size */
451 RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1);
452 RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
453 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0);
456 case 1: /* Min Address */
458 Descriptor->Io.Minimum =
459 (UINT16) InitializerOp->Asl.Value.Integer;
460 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
461 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
462 MinOp = InitializerOp;
465 case 2: /* Max Address */
467 Descriptor->Io.Maximum =
468 (UINT16) InitializerOp->Asl.Value.Integer;
469 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
470 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
471 MaxOp = InitializerOp;
474 case 3: /* Alignment */
476 Descriptor->Io.Alignment =
477 (UINT8) InitializerOp->Asl.Value.Integer;
478 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
479 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment));
480 AlignOp = InitializerOp;
485 Descriptor->Io.AddressLength =
486 (UINT8) InitializerOp->Asl.Value.Integer;
487 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
488 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength));
489 LengthOp = InitializerOp;
494 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
499 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
503 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
506 /* Validate the Min/Max/Len/Align values */
508 RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
509 Descriptor->Io.Minimum,
510 Descriptor->Io.Maximum,
511 Descriptor->Io.AddressLength,
512 Descriptor->Io.Alignment,
513 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
519 /*******************************************************************************
521 * FUNCTION: RsDoIrqDescriptor
523 * PARAMETERS: Info - Parse Op and resource template offset
525 * RETURN: Completed resource node
527 * DESCRIPTION: Construct a short "IRQ" descriptor
529 ******************************************************************************/
533 ASL_RESOURCE_INFO *Info)
535 AML_RESOURCE *Descriptor;
536 ACPI_PARSE_OBJECT *InitializerOp;
537 ASL_RESOURCE_NODE *Rnode;
538 UINT32 Interrupts = 0;
540 UINT32 CurrentByteOffset;
544 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
545 CurrentByteOffset = Info->CurrentByteOffset;
546 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ));
548 /* Length = 3 (with flag byte) */
550 Descriptor = Rnode->Buffer;
551 Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ |
552 (ASL_RDESC_IRQ_SIZE + 0x01);
554 /* Process all child initialization nodes */
556 for (i = 0; InitializerOp; i++)
560 case 0: /* Interrupt Type (or Mode - edge/level) */
562 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
563 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
564 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
567 case 1: /* Interrupt Level (or Polarity - Active high/low) */
569 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
570 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
571 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
574 case 2: /* Share Type - Default: exclusive (0) */
576 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
577 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
578 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
583 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
588 /* All IRQ bytes are handled here, after the flags and name */
590 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
592 /* Up to 16 interrupts can be specified in the list */
597 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
598 InitializerOp, NULL);
602 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
604 if (InitializerOp->Asl.Value.Integer > 15)
606 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
607 InitializerOp, NULL);
611 IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
615 /* Case 4: First IRQ value in list */
619 /* Check now for duplicates in list */
621 RsCheckListForDuplicates (InitializerOp);
623 /* Create a named field at the start of the list */
625 RsCreateWordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
626 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
631 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
634 /* Now we can set the channel mask */
636 Descriptor->Irq.IrqMask = IrqMask;
641 /*******************************************************************************
643 * FUNCTION: RsDoIrqNoFlagsDescriptor
645 * PARAMETERS: Info - Parse Op and resource template offset
647 * RETURN: Completed resource node
649 * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
651 ******************************************************************************/
654 RsDoIrqNoFlagsDescriptor (
655 ASL_RESOURCE_INFO *Info)
657 AML_RESOURCE *Descriptor;
658 ACPI_PARSE_OBJECT *InitializerOp;
659 ASL_RESOURCE_NODE *Rnode;
661 UINT32 Interrupts = 0;
662 UINT32 CurrentByteOffset;
666 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
667 CurrentByteOffset = Info->CurrentByteOffset;
668 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS));
670 Descriptor = Rnode->Buffer;
671 Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ |
674 /* Process all child initialization nodes */
676 for (i = 0; InitializerOp; i++)
682 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
687 /* IRQ bytes are handled here, after the flags and name */
689 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
691 /* Up to 16 interrupts can be specified in the list */
696 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
697 InitializerOp, NULL);
701 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
703 if (InitializerOp->Asl.Value.Integer > 15)
705 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
706 InitializerOp, NULL);
710 IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
714 /* Case 1: First IRQ value in list */
718 /* Check now for duplicates in list */
720 RsCheckListForDuplicates (InitializerOp);
722 /* Create a named field at the start of the list */
724 RsCreateWordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
725 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
730 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
733 /* Now we can set the interrupt mask */
735 Descriptor->Irq.IrqMask = IrqMask;