1 /******************************************************************************
2  *
3  * Module Name: aslrestype1i - Small I/O-related resource descriptors
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
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
19  * property rights.
20  *
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
27  *
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;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
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.
53  *
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
64  * make.
65  *
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
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
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.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
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
88  * PARTICULAR PURPOSE.
89  *
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
97  * LIMITED REMEDY.
98  *
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.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
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.
133  *
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.
145  *
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.
149  *
150  *****************************************************************************/
151 
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 
155 #define _COMPONENT          ACPI_COMPILER
156         ACPI_MODULE_NAME    ("aslrestype1i")
157 
158 /*
159  * This module contains the I/O-related small resource descriptors:
160  *
161  * DMA
162  * FixedDMA
163  * FixedIO
164  * IO
165  * IRQ
166  * IRQNoFlags
167  */
168 
169 /*******************************************************************************
170  *
171  * FUNCTION:    RsDoDmaDescriptor
172  *
173  * PARAMETERS:  Info                - Parse Op and resource template offset
174  *
175  * RETURN:      Completed resource node
176  *
177  * DESCRIPTION: Construct a short "DMA" descriptor
178  *
179  ******************************************************************************/
180 
181 ASL_RESOURCE_NODE *
RsDoDmaDescriptor(ASL_RESOURCE_INFO * Info)182 RsDoDmaDescriptor (
183     ASL_RESOURCE_INFO       *Info)
184 {
185     AML_RESOURCE            *Descriptor;
186     ACPI_PARSE_OBJECT       *InitializerOp;
187     ASL_RESOURCE_NODE       *Rnode;
188     UINT32                  CurrentByteOffset;
189     UINT32                  i;
190     UINT8                   DmaChannelMask = 0;
191     UINT8                   DmaChannels = 0;
192 
193 
194     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
195     CurrentByteOffset = Info->CurrentByteOffset;
196     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA));
197 
198     Descriptor = Rnode->Buffer;
199     Descriptor->Dma.DescriptorType =
200         ACPI_RESOURCE_NAME_DMA | ASL_RDESC_DMA_SIZE;
201 
202     /* Process all child initialization nodes */
203 
204     for (i = 0; InitializerOp; i++)
205     {
206         switch (i)
207         {
208         case 0: /* DMA type */
209 
210             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
211             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_DMATYPE,
212                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5, 2);
213             break;
214 
215         case 1: /* Bus Master */
216 
217             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
218             RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER,
219                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
220             break;
221 
222         case 2: /* Xfer Type (transfer width) */
223 
224             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
225             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_XFERTYPE,
226                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0, 2);
227             break;
228 
229         case 3: /* Name */
230 
231             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
232             break;
233 
234         default:
235 
236             /* All DMA channel bytes are handled here, after flags and name */
237 
238             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
239             {
240                 /* Up to 8 channels can be specified in the list */
241 
242                 DmaChannels++;
243                 if (DmaChannels > 8)
244                 {
245                     AslError (ASL_ERROR, ASL_MSG_DMA_LIST,
246                         InitializerOp, NULL);
247                     return (Rnode);
248                 }
249 
250                 /* Only DMA channels 0-7 are allowed (mask is 8 bits) */
251 
252                 if (InitializerOp->Asl.Value.Integer > 7)
253                 {
254                     AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL,
255                         InitializerOp, NULL);
256                 }
257 
258                 /* Build the mask */
259 
260                 DmaChannelMask |=
261                     (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
262             }
263 
264             if (i == 4) /* case 4: First DMA byte */
265             {
266                 /* Check now for duplicates in list */
267 
268                 RsCheckListForDuplicates (InitializerOp);
269 
270                 /* Create a named field at the start of the list */
271 
272                 RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA,
273                     CurrentByteOffset +
274                     ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
275             }
276             break;
277         }
278 
279         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
280     }
281 
282     /* Now we can set the channel mask */
283 
284     Descriptor->Dma.DmaChannelMask = DmaChannelMask;
285     return (Rnode);
286 }
287 
288 
289 /*******************************************************************************
290  *
291  * FUNCTION:    RsDoFixedDmaDescriptor
292  *
293  * PARAMETERS:  Info                - Parse Op and resource template offset
294  *
295  * RETURN:      Completed resource node
296  *
297  * DESCRIPTION: Construct a short "FixedDMA" descriptor
298  *
299  ******************************************************************************/
300 
301 ASL_RESOURCE_NODE *
RsDoFixedDmaDescriptor(ASL_RESOURCE_INFO * Info)302 RsDoFixedDmaDescriptor (
303     ASL_RESOURCE_INFO       *Info)
304 {
305     AML_RESOURCE            *Descriptor;
306     ACPI_PARSE_OBJECT       *InitializerOp;
307     ASL_RESOURCE_NODE       *Rnode;
308     UINT32                  CurrentByteOffset;
309     UINT32                  i;
310 
311 
312     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
313     CurrentByteOffset = Info->CurrentByteOffset;
314     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_DMA));
315 
316     Descriptor = Rnode->Buffer;
317     Descriptor->FixedDma.DescriptorType =
318         ACPI_RESOURCE_NAME_FIXED_DMA | ASL_RDESC_FIXED_DMA_SIZE;
319 
320     /* Process all child initialization nodes */
321 
322     for (i = 0; InitializerOp; i++)
323     {
324         switch (i)
325         {
326         case 0: /* DMA Request Lines [WORD] (_DMA) */
327 
328             Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
329             RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
330                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
331             break;
332 
333         case 1: /* DMA Channel [WORD] (_TYP) */
334 
335             Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
336             RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
337                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
338             break;
339 
340         case 2: /* Transfer Width [BYTE] (_SIZ) */
341 
342             Descriptor->FixedDma.Width = (UINT8) InitializerOp->Asl.Value.Integer;
343             RsCreateByteField (InitializerOp, ACPI_RESTAG_XFERTYPE,
344                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Width));
345             break;
346 
347         case 3: /* Descriptor Name (optional) */
348 
349             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
350             break;
351 
352         default:    /* Ignore any extra nodes */
353 
354             break;
355         }
356 
357         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
358     }
359 
360     return (Rnode);
361 }
362 
363 
364 /*******************************************************************************
365  *
366  * FUNCTION:    RsDoFixedIoDescriptor
367  *
368  * PARAMETERS:  Info                - Parse Op and resource template offset
369  *
370  * RETURN:      Completed resource node
371  *
372  * DESCRIPTION: Construct a short "FixedIO" descriptor
373  *
374  ******************************************************************************/
375 
376 ASL_RESOURCE_NODE *
RsDoFixedIoDescriptor(ASL_RESOURCE_INFO * Info)377 RsDoFixedIoDescriptor (
378     ASL_RESOURCE_INFO       *Info)
379 {
380     AML_RESOURCE            *Descriptor;
381     ACPI_PARSE_OBJECT       *InitializerOp;
382     ACPI_PARSE_OBJECT       *AddressOp = NULL;
383     ASL_RESOURCE_NODE       *Rnode;
384     UINT32                  CurrentByteOffset;
385     UINT32                  i;
386 
387 
388     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
389     CurrentByteOffset = Info->CurrentByteOffset;
390     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO));
391 
392     Descriptor = Rnode->Buffer;
393     Descriptor->Io.DescriptorType =
394         ACPI_RESOURCE_NAME_FIXED_IO | ASL_RDESC_FIXED_IO_SIZE;
395 
396     /* Process all child initialization nodes */
397 
398     for (i = 0; InitializerOp; i++)
399     {
400         switch (i)
401         {
402         case 0: /* Base Address */
403 
404             Descriptor->FixedIo.Address =
405                 (UINT16) InitializerOp->Asl.Value.Integer;
406             RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
407                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
408             AddressOp = InitializerOp;
409             break;
410 
411         case 1: /* Length */
412 
413             Descriptor->FixedIo.AddressLength =
414                 (UINT8) InitializerOp->Asl.Value.Integer;
415             RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
416                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength));
417             break;
418 
419         case 2: /* Name */
420 
421             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
422             break;
423 
424         default:
425 
426             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
427             break;
428         }
429 
430         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
431     }
432 
433     /* Error checks */
434 
435     if (Descriptor->FixedIo.Address > 0x03FF)
436     {
437         AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
438     }
439 
440     return (Rnode);
441 }
442 
443 
444 /*******************************************************************************
445  *
446  * FUNCTION:    RsDoIoDescriptor
447  *
448  * PARAMETERS:  Info                - Parse Op and resource template offset
449  *
450  * RETURN:      Completed resource node
451  *
452  * DESCRIPTION: Construct a short "IO" descriptor
453  *
454  ******************************************************************************/
455 
456 ASL_RESOURCE_NODE *
RsDoIoDescriptor(ASL_RESOURCE_INFO * Info)457 RsDoIoDescriptor (
458     ASL_RESOURCE_INFO       *Info)
459 {
460     AML_RESOURCE            *Descriptor;
461     ACPI_PARSE_OBJECT       *InitializerOp;
462     ACPI_PARSE_OBJECT       *MinOp = NULL;
463     ACPI_PARSE_OBJECT       *MaxOp = NULL;
464     ACPI_PARSE_OBJECT       *LengthOp = NULL;
465     ACPI_PARSE_OBJECT       *AlignOp = NULL;
466     ASL_RESOURCE_NODE       *Rnode;
467     UINT32                  CurrentByteOffset;
468     UINT32                  i;
469 
470 
471     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
472     CurrentByteOffset = Info->CurrentByteOffset;
473     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO));
474 
475     Descriptor = Rnode->Buffer;
476     Descriptor->Io.DescriptorType =
477         ACPI_RESOURCE_NAME_IO | ASL_RDESC_IO_SIZE;
478 
479     /* Process all child initialization nodes */
480 
481     for (i = 0; InitializerOp; i++)
482     {
483         switch (i)
484         {
485         case 0: /* Decode size */
486 
487             RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1);
488             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
489                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0);
490             break;
491 
492         case 1:  /* Min Address */
493 
494             Descriptor->Io.Minimum =
495                 (UINT16) InitializerOp->Asl.Value.Integer;
496             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
497                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
498             MinOp = InitializerOp;
499             break;
500 
501         case 2: /* Max Address */
502 
503             Descriptor->Io.Maximum =
504                 (UINT16) InitializerOp->Asl.Value.Integer;
505             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
506                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
507             MaxOp = InitializerOp;
508             break;
509 
510         case 3: /* Alignment */
511 
512             Descriptor->Io.Alignment =
513                 (UINT8) InitializerOp->Asl.Value.Integer;
514             RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
515                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment));
516             AlignOp = InitializerOp;
517             break;
518 
519         case 4: /* Length */
520 
521             Descriptor->Io.AddressLength =
522                 (UINT8) InitializerOp->Asl.Value.Integer;
523             RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
524                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength));
525             LengthOp = InitializerOp;
526             break;
527 
528         case 5: /* Name */
529 
530             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
531             break;
532 
533         default:
534 
535             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
536             break;
537         }
538 
539         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
540     }
541 
542     /* Validate the Min/Max/Len/Align values */
543 
544     RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
545         Descriptor->Io.Minimum,
546         Descriptor->Io.Maximum,
547         Descriptor->Io.AddressLength,
548         Descriptor->Io.Alignment,
549         MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
550 
551     return (Rnode);
552 }
553 
554 
555 /*******************************************************************************
556  *
557  * FUNCTION:    RsDoIrqDescriptor
558  *
559  * PARAMETERS:  Info                - Parse Op and resource template offset
560  *
561  * RETURN:      Completed resource node
562  *
563  * DESCRIPTION: Construct a short "IRQ" descriptor
564  *
565  ******************************************************************************/
566 
567 ASL_RESOURCE_NODE *
RsDoIrqDescriptor(ASL_RESOURCE_INFO * Info)568 RsDoIrqDescriptor (
569     ASL_RESOURCE_INFO       *Info)
570 {
571     AML_RESOURCE            *Descriptor;
572     ACPI_PARSE_OBJECT       *InitializerOp;
573     ASL_RESOURCE_NODE       *Rnode;
574     UINT32                  Interrupts = 0;
575     UINT16                  IrqMask = 0;
576     UINT32                  CurrentByteOffset;
577     UINT32                  i;
578 
579 
580     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
581     CurrentByteOffset = Info->CurrentByteOffset;
582     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ));
583 
584     /* Length = 3 (with flag byte) */
585 
586     Descriptor = Rnode->Buffer;
587     Descriptor->Irq.DescriptorType =
588         ACPI_RESOURCE_NAME_IRQ | (ASL_RDESC_IRQ_SIZE + 0x01);
589 
590     /* Process all child initialization nodes */
591 
592     for (i = 0; InitializerOp; i++)
593     {
594         switch (i)
595         {
596         case 0: /* Interrupt Type (or Mode - edge/level) */
597 
598             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
599             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
600                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
601             break;
602 
603         case 1: /* Interrupt Level (or Polarity - Active high/low) */
604 
605             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
606             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
607                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
608             break;
609 
610         case 2: /* Share Type - Default: exclusive (0) */
611 
612             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
613             RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
614                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
615             break;
616 
617         case 3: /* Name */
618 
619             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
620             break;
621 
622         default:
623 
624             /* All IRQ bytes are handled here, after the flags and name */
625 
626             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
627             {
628                 /* Up to 16 interrupts can be specified in the list */
629 
630                 Interrupts++;
631                 if (Interrupts > 16)
632                 {
633                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
634                         InitializerOp, NULL);
635                     return (Rnode);
636                 }
637 
638                 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
639 
640                 if (InitializerOp->Asl.Value.Integer > 15)
641                 {
642                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
643                         InitializerOp, NULL);
644                 }
645                 else
646                 {
647                     IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
648                 }
649             }
650 
651             /* Case 4: First IRQ value in list */
652 
653             if (i == 4)
654             {
655                 /* Check now for duplicates in list */
656 
657                 RsCheckListForDuplicates (InitializerOp);
658 
659                 /* Create a named field at the start of the list */
660 
661                 RsCreateWordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
662                     CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
663             }
664             break;
665         }
666 
667         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
668     }
669 
670     /* Now we can set the channel mask */
671 
672     Descriptor->Irq.IrqMask = IrqMask;
673     return (Rnode);
674 }
675 
676 
677 /*******************************************************************************
678  *
679  * FUNCTION:    RsDoIrqNoFlagsDescriptor
680  *
681  * PARAMETERS:  Info                - Parse Op and resource template offset
682  *
683  * RETURN:      Completed resource node
684  *
685  * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
686  *
687  ******************************************************************************/
688 
689 ASL_RESOURCE_NODE *
RsDoIrqNoFlagsDescriptor(ASL_RESOURCE_INFO * Info)690 RsDoIrqNoFlagsDescriptor (
691     ASL_RESOURCE_INFO       *Info)
692 {
693     AML_RESOURCE            *Descriptor;
694     ACPI_PARSE_OBJECT       *InitializerOp;
695     ASL_RESOURCE_NODE       *Rnode;
696     UINT16                  IrqMask = 0;
697     UINT32                  Interrupts = 0;
698     UINT32                  CurrentByteOffset;
699     UINT32                  i;
700 
701 
702     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
703     CurrentByteOffset = Info->CurrentByteOffset;
704     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS));
705 
706     Descriptor = Rnode->Buffer;
707     Descriptor->Irq.DescriptorType =
708         ACPI_RESOURCE_NAME_IRQ | ASL_RDESC_IRQ_SIZE;
709 
710     /* Process all child initialization nodes */
711 
712     for (i = 0; InitializerOp; i++)
713     {
714         switch (i)
715         {
716         case 0: /* Name */
717 
718             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
719             break;
720 
721         default:
722 
723             /* IRQ bytes are handled here, after the flags and name */
724 
725             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
726             {
727                 /* Up to 16 interrupts can be specified in the list */
728 
729                 Interrupts++;
730                 if (Interrupts > 16)
731                 {
732                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
733                         InitializerOp, NULL);
734                     return (Rnode);
735                 }
736 
737                 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
738 
739                 if (InitializerOp->Asl.Value.Integer > 15)
740                 {
741                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
742                         InitializerOp, NULL);
743                 }
744                 else
745                 {
746                     IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
747                 }
748             }
749 
750             /* Case 1: First IRQ value in list */
751 
752             if (i == 1)
753             {
754                 /* Check now for duplicates in list */
755 
756                 RsCheckListForDuplicates (InitializerOp);
757 
758                 /* Create a named field at the start of the list */
759 
760                 RsCreateWordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
761                     CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
762             }
763             break;
764         }
765 
766         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
767     }
768 
769     /* Now we can set the interrupt mask */
770 
771     Descriptor->Irq.IrqMask = IrqMask;
772     return (Rnode);
773 }
774