]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/compiler/aslrestype1.c
This commit was generated by cvs2svn to compensate for changes in r163299,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / compiler / aslrestype1.c
1
2 /******************************************************************************
3  *
4  * Module Name: aslrestype1 - Short (type1) resource templates and descriptors
5  *              $Revision: 1.35 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117
118
119 #include <contrib/dev/acpica/compiler/aslcompiler.h>
120 #include "aslcompiler.y.h"
121
122 #define _COMPONENT          ACPI_COMPILER
123         ACPI_MODULE_NAME    ("aslrestype1")
124
125
126 /*******************************************************************************
127  *
128  * FUNCTION:    RsDoDmaDescriptor
129  *
130  * PARAMETERS:  Op                  - Parent resource descriptor parse node
131  *              CurrentByteOffset   - Offset into the resource template AML
132  *                                    buffer (to track references to the desc)
133  *
134  * RETURN:      Completed resource node
135  *
136  * DESCRIPTION: Construct a short "DMA" descriptor
137  *
138  ******************************************************************************/
139
140 ASL_RESOURCE_NODE *
141 RsDoDmaDescriptor (
142     ACPI_PARSE_OBJECT       *Op,
143     UINT32                  CurrentByteOffset)
144 {
145     AML_RESOURCE            *Descriptor;
146     ACPI_PARSE_OBJECT       *InitializerOp;
147     ASL_RESOURCE_NODE       *Rnode;
148     UINT32                  i;
149     UINT8                   DmaChannelMask = 0;
150     UINT8                   DmaChannels = 0;
151
152
153     InitializerOp = Op->Asl.Child;
154     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA));
155
156     Descriptor = Rnode->Buffer;
157     Descriptor->Dma.DescriptorType  = ACPI_RESOURCE_NAME_DMA |
158                                         ASL_RDESC_DMA_SIZE;
159
160     /* Process all child initialization nodes */
161
162     for (i = 0; InitializerOp; i++)
163     {
164         switch (i)
165         {
166         case 0: /* DMA type */
167
168             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
169             RsCreateBitField (InitializerOp, ASL_RESNAME_DMATYPE,
170                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5);
171             break;
172
173         case 1: /* Bus Master */
174
175             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
176             RsCreateBitField (InitializerOp, ASL_RESNAME_BUSMASTER,
177                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
178             break;
179
180         case 2: /* Xfer Type (transfer width) */
181
182             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
183             RsCreateBitField (InitializerOp, ASL_RESNAME_XFERTYPE,
184                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0);
185             break;
186
187         case 3: /* Name */
188
189             UtAttachNamepathToOwner (Op, InitializerOp);
190             break;
191
192         default:
193
194             /* All DMA channel bytes are handled here, after flags and name */
195
196             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
197             {
198                 /* Up to 8 channels can be specified in the list */
199
200                 DmaChannels++;
201                 if (DmaChannels > 8)
202                 {
203                     AslError (ASL_ERROR, ASL_MSG_DMA_LIST,
204                         InitializerOp, NULL);
205                     return (Rnode);
206                 }
207
208                 /* Only DMA channels 0-7 are allowed (mask is 8 bits) */
209
210                 if (InitializerOp->Asl.Value.Integer > 7)
211                 {
212                     AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL,
213                         InitializerOp, NULL);
214                 }
215
216                 /* Build the mask */
217
218                 DmaChannelMask |=
219                     (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
220             }
221
222             if (i == 4) /* case 4: First DMA byte */
223             {
224                 /* Check now for duplicates in list */
225
226                 RsCheckListForDuplicates (InitializerOp);
227
228                 /* Create a named field at the start of the list */
229
230                 RsCreateByteField (InitializerOp, ASL_RESNAME_DMA,
231                     CurrentByteOffset +
232                     ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
233             }
234             break;
235         }
236
237         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
238     }
239
240     /* Now we can set the channel mask */
241
242     Descriptor->Dma.DmaChannelMask = DmaChannelMask;
243     return (Rnode);
244 }
245
246
247 /*******************************************************************************
248  *
249  * FUNCTION:    RsDoEndDependentDescriptor
250  *
251  * PARAMETERS:  Op                  - Parent resource descriptor parse node
252  *              CurrentByteOffset   - Offset into the resource template AML
253  *                                    buffer (to track references to the desc)
254  *
255  * RETURN:      Completed resource node
256  *
257  * DESCRIPTION: Construct a short "EndDependentFn" descriptor
258  *
259  ******************************************************************************/
260
261 ASL_RESOURCE_NODE *
262 RsDoEndDependentDescriptor (
263     ACPI_PARSE_OBJECT       *Op,
264     UINT32                  CurrentByteOffset)
265 {
266     AML_RESOURCE            *Descriptor;
267     ASL_RESOURCE_NODE       *Rnode;
268
269
270     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
271
272     Descriptor = Rnode->Buffer;
273     Descriptor->EndDpf.DescriptorType  = ACPI_RESOURCE_NAME_END_DEPENDENT |
274                                       ASL_RDESC_END_DEPEND_SIZE;
275     return (Rnode);
276 }
277
278
279 /*******************************************************************************
280  *
281  * FUNCTION:    RsDoFixedIoDescriptor
282  *
283  * PARAMETERS:  Op                  - Parent resource descriptor parse node
284  *              CurrentByteOffset   - Offset into the resource template AML
285  *                                    buffer (to track references to the desc)
286  *
287  * RETURN:      Completed resource node
288  *
289  * DESCRIPTION: Construct a short "FixedIO" descriptor
290  *
291  ******************************************************************************/
292
293 ASL_RESOURCE_NODE *
294 RsDoFixedIoDescriptor (
295     ACPI_PARSE_OBJECT       *Op,
296     UINT32                  CurrentByteOffset)
297 {
298     AML_RESOURCE            *Descriptor;
299     ACPI_PARSE_OBJECT       *InitializerOp;
300     ASL_RESOURCE_NODE       *Rnode;
301     UINT32                  i;
302
303
304     InitializerOp = Op->Asl.Child;
305     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO));
306
307     Descriptor = Rnode->Buffer;
308     Descriptor->Io.DescriptorType  = ACPI_RESOURCE_NAME_FIXED_IO |
309                                       ASL_RDESC_FIXED_IO_SIZE;
310
311     /* Process all child initialization nodes */
312
313     for (i = 0; InitializerOp; i++)
314     {
315         switch (i)
316         {
317         case 0: /* Base Address */
318
319             Descriptor->FixedIo.Address =
320                 (UINT16) InitializerOp->Asl.Value.Integer;
321             RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS,
322                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
323             break;
324
325         case 1: /* Length */
326
327             Descriptor->FixedIo.AddressLength =
328                 (UINT8) InitializerOp->Asl.Value.Integer;
329             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
330                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength));
331             break;
332
333         case 2: /* Name */
334
335             UtAttachNamepathToOwner (Op, InitializerOp);
336             break;
337
338         default:
339
340             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
341             break;
342         }
343
344         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
345     }
346
347     return (Rnode);
348 }
349
350
351 /*******************************************************************************
352  *
353  * FUNCTION:    RsDoIoDescriptor
354  *
355  * PARAMETERS:  Op                  - Parent resource descriptor parse node
356  *              CurrentByteOffset   - Offset into the resource template AML
357  *                                    buffer (to track references to the desc)
358  *
359  * RETURN:      Completed resource node
360  *
361  * DESCRIPTION: Construct a short "IO" descriptor
362  *
363  ******************************************************************************/
364
365 ASL_RESOURCE_NODE *
366 RsDoIoDescriptor (
367     ACPI_PARSE_OBJECT       *Op,
368     UINT32                  CurrentByteOffset)
369 {
370     AML_RESOURCE            *Descriptor;
371     ACPI_PARSE_OBJECT       *InitializerOp;
372     ASL_RESOURCE_NODE       *Rnode;
373     UINT32                  i;
374
375
376     InitializerOp = Op->Asl.Child;
377     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO));
378
379     Descriptor = Rnode->Buffer;
380     Descriptor->Io.DescriptorType  = ACPI_RESOURCE_NAME_IO |
381                                       ASL_RDESC_IO_SIZE;
382
383     /* Process all child initialization nodes */
384
385     for (i = 0; InitializerOp; i++)
386     {
387         switch (i)
388         {
389         case 0: /* Decode size */
390
391             RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1);
392             RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
393                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0);
394             break;
395
396         case 1:  /* Min Address */
397
398             Descriptor->Io.Minimum =
399                 (UINT16) InitializerOp->Asl.Value.Integer;
400             RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
401                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
402             break;
403
404         case 2: /* Max Address */
405
406             Descriptor->Io.Maximum =
407                 (UINT16) InitializerOp->Asl.Value.Integer;
408             RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
409                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
410             break;
411
412         case 3: /* Alignment */
413
414             Descriptor->Io.Alignment =
415                 (UINT8) InitializerOp->Asl.Value.Integer;
416             RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
417                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment));
418             break;
419
420         case 4: /* Length */
421
422             Descriptor->Io.AddressLength =
423                 (UINT8) InitializerOp->Asl.Value.Integer;
424             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
425                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength));
426             break;
427
428         case 5: /* Name */
429
430             UtAttachNamepathToOwner (Op, InitializerOp);
431             break;
432
433         default:
434
435             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
436             break;
437         }
438
439         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
440     }
441
442     return (Rnode);
443 }
444
445
446 /*******************************************************************************
447  *
448  * FUNCTION:    RsDoIrqDescriptor
449  *
450  * PARAMETERS:  Op                  - Parent resource descriptor parse node
451  *              CurrentByteOffset   - Offset into the resource template AML
452  *                                    buffer (to track references to the desc)
453  *
454  * RETURN:      Completed resource node
455  *
456  * DESCRIPTION: Construct a short "IRQ" descriptor
457  *
458  ******************************************************************************/
459
460 ASL_RESOURCE_NODE *
461 RsDoIrqDescriptor (
462     ACPI_PARSE_OBJECT       *Op,
463     UINT32                  CurrentByteOffset)
464 {
465     AML_RESOURCE            *Descriptor;
466     ACPI_PARSE_OBJECT       *InitializerOp;
467     ASL_RESOURCE_NODE       *Rnode;
468     UINT32                  Interrupts = 0;
469     UINT16                  IrqMask = 0;
470     UINT32                  i;
471
472
473     InitializerOp = Op->Asl.Child;
474     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ));
475
476     /* Length = 3 (with flag byte) */
477
478     Descriptor = Rnode->Buffer;
479     Descriptor->Irq.DescriptorType  = ACPI_RESOURCE_NAME_IRQ |
480                                       (ASL_RDESC_IRQ_SIZE + 0x01);
481
482     /* Process all child initialization nodes */
483
484     for (i = 0; InitializerOp; i++)
485     {
486         switch (i)
487         {
488         case 0: /* Interrupt Type (or Mode - edge/level) */
489
490             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
491             RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTTYPE,
492                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
493             break;
494
495         case 1: /* Interrupt Level (or Polarity - Active high/low) */
496
497             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
498             RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTLEVEL,
499                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
500             break;
501
502         case 2: /* Share Type - Default: exclusive (0) */
503
504             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
505             RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTSHARE,
506                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
507             break;
508
509         case 3: /* Name */
510
511             UtAttachNamepathToOwner (Op, InitializerOp);
512             break;
513
514         default:
515
516             /* All IRQ bytes are handled here, after the flags and name */
517
518             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
519             {
520                 /* Up to 16 interrupts can be specified in the list */
521
522                 Interrupts++;
523                 if (Interrupts > 16)
524                 {
525                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
526                         InitializerOp, NULL);
527                     return (Rnode);
528                 }
529
530                 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
531
532                 if (InitializerOp->Asl.Value.Integer > 15)
533                 {
534                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
535                         InitializerOp, NULL);
536                 }
537                 else
538                 {
539                     IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
540                 }
541             }
542
543             /* Case 4: First IRQ value in list */
544
545             if (i == 4)
546             {
547                 /* Check now for duplicates in list */
548
549                 RsCheckListForDuplicates (InitializerOp);
550
551                 /* Create a named field at the start of the list */
552
553                 RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
554                     CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
555             }
556             break;
557         }
558
559         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
560     }
561
562     /* Now we can set the channel mask */
563
564     Descriptor->Irq.IrqMask = IrqMask;
565     return (Rnode);
566 }
567
568
569 /*******************************************************************************
570  *
571  * FUNCTION:    RsDoIrqNoFlagsDescriptor
572  *
573  * PARAMETERS:  Op                  - Parent resource descriptor parse node
574  *              CurrentByteOffset   - Offset into the resource template AML
575  *                                    buffer (to track references to the desc)
576  *
577  * RETURN:      Completed resource node
578  *
579  * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
580  *
581  ******************************************************************************/
582
583 ASL_RESOURCE_NODE *
584 RsDoIrqNoFlagsDescriptor (
585     ACPI_PARSE_OBJECT       *Op,
586     UINT32                  CurrentByteOffset)
587 {
588     AML_RESOURCE            *Descriptor;
589     ACPI_PARSE_OBJECT       *InitializerOp;
590     ASL_RESOURCE_NODE       *Rnode;
591     UINT16                  IrqMask = 0;
592     UINT32                  Interrupts = 0;
593     UINT32                  i;
594
595
596     InitializerOp = Op->Asl.Child;
597     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS));
598
599     Descriptor = Rnode->Buffer;
600     Descriptor->Irq.DescriptorType  = ACPI_RESOURCE_NAME_IRQ |
601                                       ASL_RDESC_IRQ_SIZE;
602
603     /* Process all child initialization nodes */
604
605     for (i = 0; InitializerOp; i++)
606     {
607         switch (i)
608         {
609         case 0: /* Name */
610
611             UtAttachNamepathToOwner (Op, InitializerOp);
612             break;
613
614         default:
615
616             /* IRQ bytes are handled here, after the flags and name */
617
618             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
619             {
620                 /* Up to 16 interrupts can be specified in the list */
621
622                 Interrupts++;
623                 if (Interrupts > 16)
624                 {
625                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
626                         InitializerOp, NULL);
627                     return (Rnode);
628                 }
629
630                 /* Only interrupts 0-15 are allowed (mask is 16 bits) */
631
632                 if (InitializerOp->Asl.Value.Integer > 15)
633                 {
634                     AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
635                         InitializerOp, NULL);
636                 }
637                 else
638                 {
639                     IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
640                 }
641             }
642
643             /* Case 1: First IRQ value in list */
644
645             if (i == 1)
646             {
647                 /* Check now for duplicates in list */
648
649                 RsCheckListForDuplicates (InitializerOp);
650
651                 /* Create a named field at the start of the list */
652
653                 RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
654                     CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
655             }
656             break;
657         }
658
659         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
660     }
661
662     /* Now we can set the interrupt mask */
663
664     Descriptor->Irq.IrqMask = IrqMask;
665     return (Rnode);
666 }
667
668
669 /*******************************************************************************
670  *
671  * FUNCTION:    RsDoMemory24Descriptor
672  *
673  * PARAMETERS:  Op                  - Parent resource descriptor parse node
674  *              CurrentByteOffset   - Offset into the resource template AML
675  *                                    buffer (to track references to the desc)
676  *
677  * RETURN:      Completed resource node
678  *
679  * DESCRIPTION: Construct a short "Memory24" descriptor
680  *
681  ******************************************************************************/
682
683 ASL_RESOURCE_NODE *
684 RsDoMemory24Descriptor (
685     ACPI_PARSE_OBJECT       *Op,
686     UINT32                  CurrentByteOffset)
687 {
688     AML_RESOURCE            *Descriptor;
689     ACPI_PARSE_OBJECT       *InitializerOp;
690     ASL_RESOURCE_NODE       *Rnode;
691     UINT32                  i;
692
693
694     InitializerOp = Op->Asl.Child;
695     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
696
697     Descriptor = Rnode->Buffer;
698     Descriptor->Memory24.DescriptorType  = ACPI_RESOURCE_NAME_MEMORY24;
699     Descriptor->Memory24.ResourceLength = 9;
700
701     /* Process all child initialization nodes */
702
703     for (i = 0; InitializerOp; i++)
704     {
705         switch (i)
706         {
707         case 0: /* Read/Write type */
708
709             RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
710             RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
711                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
712             break;
713
714         case 1: /* Min Address */
715
716             Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
717             RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
718                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
719             break;
720
721         case 2: /* Max Address */
722
723             Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
724             RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
725                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
726             break;
727
728         case 3: /* Alignment */
729
730             Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
731             RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
732                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
733             break;
734
735         case 4: /* Length */
736
737             Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
738             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
739                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
740             break;
741
742         case 5: /* Name */
743
744             UtAttachNamepathToOwner (Op, InitializerOp);
745             break;
746
747         default:
748
749             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
750             break;
751         }
752
753         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
754     }
755
756     return (Rnode);
757 }
758
759
760 /*******************************************************************************
761  *
762  * FUNCTION:    RsDoMemory32Descriptor
763  *
764  * PARAMETERS:  Op                  - Parent resource descriptor parse node
765  *              CurrentByteOffset   - Offset into the resource template AML
766  *                                    buffer (to track references to the desc)
767  *
768  * RETURN:      Completed resource node
769  *
770  * DESCRIPTION: Construct a short "Memory32" descriptor
771  *
772  ******************************************************************************/
773
774 ASL_RESOURCE_NODE *
775 RsDoMemory32Descriptor (
776     ACPI_PARSE_OBJECT       *Op,
777     UINT32                  CurrentByteOffset)
778 {
779     AML_RESOURCE            *Descriptor;
780     ACPI_PARSE_OBJECT       *InitializerOp;
781     ASL_RESOURCE_NODE       *Rnode;
782     UINT32                  i;
783
784
785     InitializerOp = Op->Asl.Child;
786     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
787
788     Descriptor = Rnode->Buffer;
789     Descriptor->Memory32.DescriptorType  = ACPI_RESOURCE_NAME_MEMORY32;
790     Descriptor->Memory32.ResourceLength = 17;
791
792     /* Process all child initialization nodes */
793
794     for (i = 0; InitializerOp; i++)
795     {
796         switch (i)
797         {
798         case 0: /* Read/Write type */
799
800             RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
801             RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
802                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
803             break;
804
805         case 1:  /* Min Address */
806
807             Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
808             RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
809                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
810             break;
811
812         case 2: /* Max Address */
813
814             Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
815             RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
816                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
817             break;
818
819         case 3: /* Alignment */
820
821             Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
822             RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
823                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
824             break;
825
826         case 4: /* Length */
827
828             Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
829             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
830                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
831             break;
832
833         case 5: /* Name */
834
835             UtAttachNamepathToOwner (Op, InitializerOp);
836             break;
837
838         default:
839
840             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
841             break;
842         }
843
844         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
845     }
846
847     return (Rnode);
848 }
849
850
851 /*******************************************************************************
852  *
853  * FUNCTION:    RsDoMemory32FixedDescriptor
854  *
855  * PARAMETERS:  Op                  - Parent resource descriptor parse node
856  *              CurrentByteOffset   - Offset into the resource template AML
857  *                                    buffer (to track references to the desc)
858  *
859  * RETURN:      Completed resource node
860  *
861  * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
862  *
863  ******************************************************************************/
864
865 ASL_RESOURCE_NODE *
866 RsDoMemory32FixedDescriptor (
867     ACPI_PARSE_OBJECT       *Op,
868     UINT32                  CurrentByteOffset)
869 {
870     AML_RESOURCE            *Descriptor;
871     ACPI_PARSE_OBJECT       *InitializerOp;
872     ASL_RESOURCE_NODE       *Rnode;
873     UINT32                  i;
874
875
876     InitializerOp = Op->Asl.Child;
877     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
878
879     Descriptor = Rnode->Buffer;
880     Descriptor->FixedMemory32.DescriptorType  = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
881     Descriptor->FixedMemory32.ResourceLength = 9;
882
883     /* Process all child initialization nodes */
884
885     for (i = 0; InitializerOp; i++)
886     {
887         switch (i)
888         {
889         case 0: /* Read/Write type */
890
891             RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
892             RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
893                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
894             break;
895
896         case 1: /* Address */
897
898             Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
899             RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS,
900                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
901             break;
902
903         case 2: /* Length */
904
905             Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
906             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
907                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
908             break;
909
910         case 3: /* Name */
911
912             UtAttachNamepathToOwner (Op, InitializerOp);
913             break;
914
915         default:
916
917             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
918             break;
919         }
920
921         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
922     }
923
924     return (Rnode);
925 }
926
927
928 /*******************************************************************************
929  *
930  * FUNCTION:    RsDoStartDependentDescriptor
931  *
932  * PARAMETERS:  Op                  - Parent resource descriptor parse node
933  *              CurrentByteOffset   - Offset into the resource template AML
934  *                                    buffer (to track references to the desc)
935  *
936  * RETURN:      Completed resource node
937  *
938  * DESCRIPTION: Construct a short "StartDependentFn" descriptor
939  *
940  ******************************************************************************/
941
942 ASL_RESOURCE_NODE *
943 RsDoStartDependentDescriptor (
944     ACPI_PARSE_OBJECT       *Op,
945     UINT32                  CurrentByteOffset)
946 {
947     AML_RESOURCE            *Descriptor;
948     ACPI_PARSE_OBJECT       *InitializerOp;
949     ASL_RESOURCE_NODE       *Rnode;
950     ASL_RESOURCE_NODE       *PreviousRnode;
951     ASL_RESOURCE_NODE       *NextRnode;
952     UINT32                  i;
953     UINT8                   State;
954
955
956     InitializerOp = Op->Asl.Child;
957     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
958
959     PreviousRnode = Rnode;
960     Descriptor = Rnode->Buffer;
961
962     /* Descriptor has priority byte */
963
964     Descriptor->StartDpf.DescriptorType  = ACPI_RESOURCE_NAME_START_DEPENDENT |
965                                       (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
966
967     /* Process all child initialization nodes */
968
969     State = ACPI_RSTATE_START_DEPENDENT;
970     for (i = 0; InitializerOp; i++)
971     {
972         switch (i)
973         {
974         case 0: /* Compatibility Priority */
975
976             if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
977             {
978                 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
979                     InitializerOp, NULL);
980             }
981
982             RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
983             break;
984
985         case 1: /* Performance/Robustness Priority */
986
987             if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
988             {
989                 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
990                     InitializerOp, NULL);
991             }
992
993             RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
994             break;
995
996         default:
997             NextRnode = RsDoOneResourceDescriptor  (InitializerOp,
998                         CurrentByteOffset, &State);
999
1000             /*
1001              * Update current byte offset to indicate the number of bytes from the
1002              * start of the buffer.  Buffer can include multiple descriptors, we
1003              * must keep track of the offset of not only each descriptor, but each
1004              * element (field) within each descriptor as well.
1005              */
1006
1007             CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode,
1008                                     NextRnode);
1009             break;
1010         }
1011
1012         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1013     }
1014
1015     return (Rnode);
1016 }
1017
1018
1019 /*******************************************************************************
1020  *
1021  * FUNCTION:    RsDoStartDependentNoPriDescriptor
1022  *
1023  * PARAMETERS:  Op                  - Parent resource descriptor parse node
1024  *              CurrentByteOffset   - Offset into the resource template AML
1025  *                                    buffer (to track references to the desc)
1026  *
1027  * RETURN:      Completed resource node
1028  *
1029  * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
1030  *
1031  ******************************************************************************/
1032
1033 ASL_RESOURCE_NODE *
1034 RsDoStartDependentNoPriDescriptor (
1035     ACPI_PARSE_OBJECT       *Op,
1036     UINT32                  CurrentByteOffset)
1037 {
1038     AML_RESOURCE            *Descriptor;
1039     ACPI_PARSE_OBJECT       *InitializerOp;
1040     ASL_RESOURCE_NODE       *Rnode;
1041     ASL_RESOURCE_NODE       *PreviousRnode;
1042     ASL_RESOURCE_NODE       *NextRnode;
1043     UINT8                   State;
1044
1045
1046     InitializerOp = Op->Asl.Child;
1047     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
1048
1049     Descriptor = Rnode->Buffer;
1050     Descriptor->StartDpf.DescriptorType  = ACPI_RESOURCE_NAME_START_DEPENDENT |
1051                                       ASL_RDESC_ST_DEPEND_SIZE;
1052     PreviousRnode = Rnode;
1053
1054     /* Process all child initialization nodes */
1055
1056     State = ACPI_RSTATE_START_DEPENDENT;
1057     while (InitializerOp)
1058     {
1059         NextRnode = RsDoOneResourceDescriptor  (InitializerOp,
1060                         CurrentByteOffset, &State);
1061
1062         /*
1063          * Update current byte offset to indicate the number of bytes from the
1064          * start of the buffer.  Buffer can include multiple descriptors, we
1065          * must keep track of the offset of not only each descriptor, but each
1066          * element (field) within each descriptor as well.
1067          */
1068         CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
1069
1070         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1071     }
1072
1073     return (Rnode);
1074 }
1075
1076
1077 /*******************************************************************************
1078  *
1079  * FUNCTION:    RsDoVendorSmallDescriptor
1080  *
1081  * PARAMETERS:  Op                  - Parent resource descriptor parse node
1082  *              CurrentByteOffset   - Offset into the resource template AML
1083  *                                    buffer (to track references to the desc)
1084  *
1085  * RETURN:      Completed resource node
1086  *
1087  * DESCRIPTION: Construct a short "VendorShort" descriptor
1088  *
1089  ******************************************************************************/
1090
1091 ASL_RESOURCE_NODE *
1092 RsDoVendorSmallDescriptor (
1093     ACPI_PARSE_OBJECT       *Op,
1094     UINT32                  CurrentByteOffset)
1095 {
1096     AML_RESOURCE            *Descriptor;
1097     ACPI_PARSE_OBJECT       *InitializerOp;
1098     ASL_RESOURCE_NODE       *Rnode;
1099     UINT8                   *VendorData;
1100     UINT32                  i;
1101
1102
1103     InitializerOp = Op->Asl.Child;
1104
1105     /* Allocate worst case - 7 vendor bytes */
1106
1107     Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
1108
1109     Descriptor = Rnode->Buffer;
1110     Descriptor->VendorSmall.DescriptorType  = ACPI_RESOURCE_NAME_VENDOR_SMALL;
1111     VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
1112
1113     /* Process all child initialization nodes */
1114
1115     InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1116     for (i = 0; InitializerOp; i++)
1117     {
1118         /* Maximum 7 vendor data bytes allowed (0-6) */
1119
1120         if (i >= 7)
1121         {
1122             AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
1123
1124             /* Eat the excess initializers */
1125
1126             while (InitializerOp)
1127             {
1128                 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1129             }
1130             break;
1131         }
1132
1133         VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
1134         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1135     }
1136
1137     /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
1138
1139     Rnode->BufferLength -= (7 - i);
1140
1141     /* Set the length in the Type Tag */
1142
1143     Descriptor->VendorSmall.DescriptorType |= (UINT8) i;
1144     return (Rnode);
1145 }
1146
1147