Update ACPI build wrappers to use new ACPICA(20050309) code.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20050211 / compiler / aslrestype1.c
1
2 /******************************************************************************
3  *
4  * Module Name: aslrestype1 - Short (type1) resource templates and descriptors
5  *              $Revision: 29 $
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 "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     ASL_RESOURCE_DESC       *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 (ASL_DMA_FORMAT_DESC));
155
156     Descriptor = Rnode->Buffer;
157     Descriptor->Dma.DescriptorType  = ACPI_RDESC_TYPE_DMA_FORMAT |
158                                         ASL_RDESC_DMA_SIZE;
159
160     /*
161      * Process all child initialization nodes
162      */
163     for (i = 0; InitializerOp; i++)
164     {
165         switch (i)
166         {
167         case 0: /* DMA type */
168
169             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
170             RsCreateBitField (InitializerOp, ASL_RESNAME_DMATYPE,
171                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5);
172             break;
173
174         case 1: /* Bus Master */
175
176             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
177             RsCreateBitField (InitializerOp, ASL_RESNAME_BUSMASTER,
178                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
179             break;
180
181         case 2: /* Xfer Type (transfer width) */
182
183             RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
184             RsCreateBitField (InitializerOp, ASL_RESNAME_XFERTYPE,
185                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0);
186             break;
187
188         case 3: /* Name */
189
190             UtAttachNamepathToOwner (Op, InitializerOp);
191             break;
192
193         default:
194
195             /* All DMA channel bytes are handled here, after the flags and name */
196
197             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
198             {
199                 /* Up to 8 channels can be specified in the list */
200
201                 DmaChannels++;
202                 if (DmaChannels > 8)
203                 {
204                     AslError (ASL_ERROR, ASL_MSG_DMA_LIST, 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, InitializerOp, NULL);
213                 }
214
215                 /* Build the mask */
216
217                 DmaChannelMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
218             }
219
220             if (i == 4) /* case 4: First DMA byte */
221             {
222                 RsCreateByteField (InitializerOp, ASL_RESNAME_DMA,
223                     CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
224             }
225             break;
226         }
227
228         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
229     }
230
231     /* Now we can set the channel mask */
232
233     Descriptor->Dma.DmaChannelMask = DmaChannelMask;
234     return (Rnode);
235 }
236
237
238 /*******************************************************************************
239  *
240  * FUNCTION:    RsDoEndDependentDescriptor
241  *
242  * PARAMETERS:  Op                  - Parent resource descriptor parse node
243  *              CurrentByteOffset   - Offset into the resource template AML
244  *                                    buffer (to track references to the desc)
245  *
246  * RETURN:      Completed resource node
247  *
248  * DESCRIPTION: Construct a short "EndDependentFn" descriptor
249  *
250  ******************************************************************************/
251
252 ASL_RESOURCE_NODE *
253 RsDoEndDependentDescriptor (
254     ACPI_PARSE_OBJECT       *Op,
255     UINT32                  CurrentByteOffset)
256 {
257     ASL_RESOURCE_DESC       *Descriptor;
258     ASL_RESOURCE_NODE       *Rnode;
259
260
261     Rnode = RsAllocateResourceNode (sizeof (ASL_END_DEPENDENT_DESC));
262
263     Descriptor = Rnode->Buffer;
264     Descriptor->End.DescriptorType  = ACPI_RDESC_TYPE_END_DEPENDENT |
265                                         ASL_RDESC_END_DEPEND_SIZE;
266     return (Rnode);
267 }
268
269
270 /*******************************************************************************
271  *
272  * FUNCTION:    RsDoFixedIoDescriptor
273  *
274  * PARAMETERS:  Op                  - Parent resource descriptor parse node
275  *              CurrentByteOffset   - Offset into the resource template AML
276  *                                    buffer (to track references to the desc)
277  *
278  * RETURN:      Completed resource node
279  *
280  * DESCRIPTION: Construct a short "FixedIO" descriptor
281  *
282  ******************************************************************************/
283
284 ASL_RESOURCE_NODE *
285 RsDoFixedIoDescriptor (
286     ACPI_PARSE_OBJECT       *Op,
287     UINT32                  CurrentByteOffset)
288 {
289     ASL_RESOURCE_DESC       *Descriptor;
290     ACPI_PARSE_OBJECT       *InitializerOp;
291     ASL_RESOURCE_NODE       *Rnode;
292     UINT32                  i;
293
294
295     InitializerOp = Op->Asl.Child;
296     Rnode = RsAllocateResourceNode (sizeof (ASL_FIXED_IO_PORT_DESC));
297
298     Descriptor = Rnode->Buffer;
299     Descriptor->Iop.DescriptorType  = ACPI_RDESC_TYPE_FIXED_IO_PORT |
300                                         ASL_RDESC_FIXED_IO_SIZE;
301
302     /*
303      * Process all child initialization nodes
304      */
305     for (i = 0; InitializerOp; i++)
306     {
307         switch (i)
308         {
309         case 0: /* Base Address */
310
311             Descriptor->Fio.BaseAddress = (UINT16) InitializerOp->Asl.Value.Integer;
312             RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS,
313                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Fio.BaseAddress));
314             break;
315
316         case 1: /* Length */
317
318             Descriptor->Fio.Length = (UINT8) InitializerOp->Asl.Value.Integer;
319             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
320                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Fio.Length));
321             break;
322
323         case 2: /* Name */
324
325             UtAttachNamepathToOwner (Op, InitializerOp);
326             break;
327
328         default:
329
330             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
331             break;
332         }
333
334         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
335     }
336
337     return (Rnode);
338 }
339
340
341 /*******************************************************************************
342  *
343  * FUNCTION:    RsDoIoDescriptor
344  *
345  * PARAMETERS:  Op                  - Parent resource descriptor parse node
346  *              CurrentByteOffset   - Offset into the resource template AML
347  *                                    buffer (to track references to the desc)
348  *
349  * RETURN:      Completed resource node
350  *
351  * DESCRIPTION: Construct a short "IO" descriptor
352  *
353  ******************************************************************************/
354
355 ASL_RESOURCE_NODE *
356 RsDoIoDescriptor (
357     ACPI_PARSE_OBJECT       *Op,
358     UINT32                  CurrentByteOffset)
359 {
360     ASL_RESOURCE_DESC       *Descriptor;
361     ACPI_PARSE_OBJECT       *InitializerOp;
362     ASL_RESOURCE_NODE       *Rnode;
363     UINT32                  i;
364
365
366     InitializerOp = Op->Asl.Child;
367     Rnode = RsAllocateResourceNode (sizeof (ASL_IO_PORT_DESC));
368
369     Descriptor = Rnode->Buffer;
370     Descriptor->Iop.DescriptorType  = ACPI_RDESC_TYPE_IO_PORT |
371                                         ASL_RDESC_IO_SIZE;
372
373     /*
374      * Process all child initialization nodes
375      */
376     for (i = 0; InitializerOp; i++)
377     {
378         switch (i)
379         {
380         case 0: /* Decode size */
381
382             RsSetFlagBits (&Descriptor->Iop.Information, InitializerOp, 0, 1);
383             RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE,
384                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Information), 0);
385             break;
386
387         case 1:  /* Min Address */
388
389             Descriptor->Iop.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer;
390             RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
391                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.AddressMin));
392             break;
393
394         case 2: /* Max Address */
395
396             Descriptor->Iop.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer;
397             RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
398                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.AddressMax));
399             break;
400
401         case 3: /* Alignment */
402
403             Descriptor->Iop.Alignment = (UINT8) InitializerOp->Asl.Value.Integer;
404             RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
405                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Alignment));
406             break;
407
408         case 4: /* Length */
409
410             Descriptor->Iop.Length = (UINT8) InitializerOp->Asl.Value.Integer;
411             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
412                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Length));
413             break;
414
415         case 5: /* Name */
416
417             UtAttachNamepathToOwner (Op, InitializerOp);
418             break;
419
420         default:
421
422             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
423             break;
424         }
425
426         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
427     }
428
429     return (Rnode);
430 }
431
432
433 /*******************************************************************************
434  *
435  * FUNCTION:    RsDoIrqDescriptor
436  *
437  * PARAMETERS:  Op                  - Parent resource descriptor parse node
438  *              CurrentByteOffset   - Offset into the resource template AML
439  *                                    buffer (to track references to the desc)
440  *
441  * RETURN:      Completed resource node
442  *
443  * DESCRIPTION: Construct a short "IRQ" descriptor
444  *
445  ******************************************************************************/
446
447 ASL_RESOURCE_NODE *
448 RsDoIrqDescriptor (
449     ACPI_PARSE_OBJECT       *Op,
450     UINT32                  CurrentByteOffset)
451 {
452     ASL_RESOURCE_DESC       *Descriptor;
453     ACPI_PARSE_OBJECT       *InitializerOp;
454     ASL_RESOURCE_NODE       *Rnode;
455     UINT32                  i;
456     UINT16                  IrqMask = 0;
457
458
459     InitializerOp = Op->Asl.Child;
460     Rnode = RsAllocateResourceNode (sizeof (ASL_IRQ_FORMAT_DESC));
461
462     /* Length = 3 (with flag byte) */
463
464     Descriptor = Rnode->Buffer;
465     Descriptor->Irq.DescriptorType  = ACPI_RDESC_TYPE_IRQ_FORMAT |
466                                         (ASL_RDESC_IRQ_SIZE + 0x01);
467
468     /*
469      * Process all child initialization nodes
470      */
471     for (i = 0; InitializerOp; i++)
472     {
473         switch (i)
474         {
475         case 0: /* Interrupt Type (or Mode - edge/level) */
476
477             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
478             RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTTYPE,
479                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
480             break;
481
482         case 1: /* Interrupt Level (or Polarity - Active high/low) */
483
484             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
485             RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTLEVEL,
486                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
487             break;
488
489         case 2: /* Share Type - Default: exclusive (0) */
490
491             RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
492             RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTSHARE,
493                                 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
494             break;
495
496         case 3: /* Name */
497
498             UtAttachNamepathToOwner (Op, InitializerOp);
499             break;
500
501         default:
502
503             /* All IRQ bytes are handled here, after the flags and name */
504
505             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
506             {
507                 IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
508             }
509
510             if (i == 4) /* case 4: First IRQ byte */
511             {
512                 RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
513                                     CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
514             }
515             break;
516         }
517
518         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
519     }
520
521     /* Now we can set the channel mask */
522
523     Descriptor->Irq.IrqMask = IrqMask;
524     return (Rnode);
525 }
526
527
528 /*******************************************************************************
529  *
530  * FUNCTION:    RsDoIrqNoFlagsDescriptor
531  *
532  * PARAMETERS:  Op                  - Parent resource descriptor parse node
533  *              CurrentByteOffset   - Offset into the resource template AML
534  *                                    buffer (to track references to the desc)
535  *
536  * RETURN:      Completed resource node
537  *
538  * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
539  *
540  ******************************************************************************/
541
542 ASL_RESOURCE_NODE *
543 RsDoIrqNoFlagsDescriptor (
544     ACPI_PARSE_OBJECT       *Op,
545     UINT32                  CurrentByteOffset)
546 {
547     ASL_RESOURCE_DESC       *Descriptor;
548     ACPI_PARSE_OBJECT       *InitializerOp;
549     ASL_RESOURCE_NODE       *Rnode;
550     UINT32                  i;
551     UINT16                  IrqMask = 0;
552
553
554     InitializerOp = Op->Asl.Child;
555     Rnode = RsAllocateResourceNode (sizeof (ASL_IRQ_NOFLAGS_DESC));
556
557     Descriptor = Rnode->Buffer;
558     Descriptor->Irq.DescriptorType  = ACPI_RDESC_TYPE_IRQ_FORMAT |
559                                         ASL_RDESC_IRQ_SIZE;
560
561     /*
562      * Process all child initialization nodes
563      */
564     for (i = 0; InitializerOp; i++)
565     {
566         switch (i)
567         {
568         case 0: /* Name */
569
570             UtAttachNamepathToOwner (Op, InitializerOp);
571             break;
572
573         default:
574
575             /* IRQ bytes are handled here, after the flags and name */
576
577             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
578             {
579                 IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
580             }
581
582             if (i == 1) /* case 1: First IRQ byte */
583             {
584                 RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT,
585                                     CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
586             }
587             break;
588         }
589
590         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
591     }
592
593     /* Now we can set the interrupt mask */
594
595     Descriptor->Irq.IrqMask = IrqMask;
596     return (Rnode);
597 }
598
599
600 /*******************************************************************************
601  *
602  * FUNCTION:    RsDoMemory24Descriptor
603  *
604  * PARAMETERS:  Op                  - Parent resource descriptor parse node
605  *              CurrentByteOffset   - Offset into the resource template AML
606  *                                    buffer (to track references to the desc)
607  *
608  * RETURN:      Completed resource node
609  *
610  * DESCRIPTION: Construct a short "Memory24" descriptor
611  *
612  ******************************************************************************/
613
614 ASL_RESOURCE_NODE *
615 RsDoMemory24Descriptor (
616     ACPI_PARSE_OBJECT       *Op,
617     UINT32                  CurrentByteOffset)
618 {
619     ASL_RESOURCE_DESC       *Descriptor;
620     ACPI_PARSE_OBJECT       *InitializerOp;
621     ASL_RESOURCE_NODE       *Rnode;
622     UINT32                  i;
623
624
625     InitializerOp = Op->Asl.Child;
626     Rnode = RsAllocateResourceNode (sizeof (ASL_MEMORY_24_DESC));
627
628     Descriptor = Rnode->Buffer;
629     Descriptor->M24.DescriptorType  = ACPI_RDESC_TYPE_MEMORY_24;
630     Descriptor->M24.Length = 9;
631
632     /*
633      * Process all child initialization nodes
634      */
635     for (i = 0; InitializerOp; i++)
636     {
637         switch (i)
638         {
639         case 0: /* Read/Write type */
640
641             RsSetFlagBits (&Descriptor->M24.Information, InitializerOp, 0, 1);
642             RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
643                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M24.Information), 0);
644             break;
645
646         case 1: /* Min Address */
647
648             Descriptor->M24.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer;
649             RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
650                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M24.AddressMin));
651             break;
652
653         case 2: /* Max Address */
654
655             Descriptor->M24.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer;
656             RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
657                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M24.AddressMax));
658             break;
659
660         case 3: /* Alignment */
661
662             Descriptor->M24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
663             RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
664                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M24.Alignment));
665             break;
666
667         case 4: /* Length */
668
669             Descriptor->M24.RangeLength = (UINT16) InitializerOp->Asl.Value.Integer;
670             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
671                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M24.RangeLength));
672             break;
673
674         case 5: /* Name */
675
676             UtAttachNamepathToOwner (Op, InitializerOp);
677             break;
678
679         default:
680
681             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
682             break;
683         }
684
685         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
686     }
687
688     return (Rnode);
689 }
690
691
692 /*******************************************************************************
693  *
694  * FUNCTION:    RsDoMemory32Descriptor
695  *
696  * PARAMETERS:  Op                  - Parent resource descriptor parse node
697  *              CurrentByteOffset   - Offset into the resource template AML
698  *                                    buffer (to track references to the desc)
699  *
700  * RETURN:      Completed resource node
701  *
702  * DESCRIPTION: Construct a short "Memory32" descriptor
703  *
704  ******************************************************************************/
705
706 ASL_RESOURCE_NODE *
707 RsDoMemory32Descriptor (
708     ACPI_PARSE_OBJECT       *Op,
709     UINT32                  CurrentByteOffset)
710 {
711     ASL_RESOURCE_DESC       *Descriptor;
712     ACPI_PARSE_OBJECT       *InitializerOp;
713     ASL_RESOURCE_NODE       *Rnode;
714     UINT32                  i;
715
716
717     InitializerOp = Op->Asl.Child;
718     Rnode = RsAllocateResourceNode (sizeof (ASL_MEMORY_32_DESC));
719
720     Descriptor = Rnode->Buffer;
721     Descriptor->M32.DescriptorType  = ACPI_RDESC_TYPE_MEMORY_32;
722     Descriptor->M32.Length = 17;
723
724     /*
725      * Process all child initialization nodes
726      */
727     for (i = 0; InitializerOp; i++)
728     {
729         switch (i)
730         {
731         case 0: /* Read/Write type */
732
733             RsSetFlagBits (&Descriptor->M32.Information, InitializerOp, 0, 1);
734             RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
735                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M32.Information), 0);
736             break;
737
738         case 1:  /* Min Address */
739
740             Descriptor->M32.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer;
741             RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR,
742                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M32.AddressMin));
743             break;
744
745         case 2: /* Max Address */
746
747             Descriptor->M32.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer;
748             RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR,
749                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M32.AddressMax));
750             break;
751
752         case 3: /* Alignment */
753
754             Descriptor->M32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
755             RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT,
756                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M32.Alignment));
757             break;
758
759         case 4: /* Length */
760
761             Descriptor->M32.RangeLength = (UINT32) InitializerOp->Asl.Value.Integer;
762             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
763                                 CurrentByteOffset + ASL_RESDESC_OFFSET (M32.RangeLength));
764             break;
765
766         case 5: /* Name */
767
768             UtAttachNamepathToOwner (Op, InitializerOp);
769             break;
770
771         default:
772
773             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
774             break;
775         }
776
777         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
778     }
779
780     return (Rnode);
781 }
782
783
784 /*******************************************************************************
785  *
786  * FUNCTION:    RsDoMemory32FixedDescriptor
787  *
788  * PARAMETERS:  Op                  - Parent resource descriptor parse node
789  *              CurrentByteOffset   - Offset into the resource template AML
790  *                                    buffer (to track references to the desc)
791  *
792  * RETURN:      Completed resource node
793  *
794  * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
795  *
796  ******************************************************************************/
797
798 ASL_RESOURCE_NODE *
799 RsDoMemory32FixedDescriptor (
800     ACPI_PARSE_OBJECT       *Op,
801     UINT32                  CurrentByteOffset)
802 {
803     ASL_RESOURCE_DESC       *Descriptor;
804     ACPI_PARSE_OBJECT       *InitializerOp;
805     ASL_RESOURCE_NODE       *Rnode;
806     UINT32                  i;
807
808
809     InitializerOp = Op->Asl.Child;
810     Rnode = RsAllocateResourceNode (sizeof (ASL_FIXED_MEMORY_32_DESC));
811
812     Descriptor = Rnode->Buffer;
813     Descriptor->F32.DescriptorType  = ACPI_RDESC_TYPE_FIXED_MEMORY_32;
814     Descriptor->F32.Length = 9;
815
816     /*
817      * Process all child initialization nodes
818      */
819     for (i = 0; InitializerOp; i++)
820     {
821         switch (i)
822         {
823         case 0: /* Read/Write type */
824
825             RsSetFlagBits (&Descriptor->F32.Information, InitializerOp, 0, 1);
826             RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE,
827                                 CurrentByteOffset + ASL_RESDESC_OFFSET (F32.Information), 0);
828             break;
829
830         case 1: /* Address */
831
832             Descriptor->F32.BaseAddress = (UINT32) InitializerOp->Asl.Value.Integer;
833             RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS,
834                                 CurrentByteOffset + ASL_RESDESC_OFFSET (F32.BaseAddress));
835             break;
836
837         case 2: /* Length */
838
839             Descriptor->F32.RangeLength = (UINT32) InitializerOp->Asl.Value.Integer;
840             RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH,
841                                 CurrentByteOffset + ASL_RESDESC_OFFSET (F32.RangeLength));
842             break;
843
844         case 3: /* Name */
845
846             UtAttachNamepathToOwner (Op, InitializerOp);
847             break;
848
849         default:
850
851             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
852             break;
853         }
854
855         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
856     }
857
858     return (Rnode);
859 }
860
861
862 /*******************************************************************************
863  *
864  * FUNCTION:    RsDoStartDependentDescriptor
865  *
866  * PARAMETERS:  Op                  - Parent resource descriptor parse node
867  *              CurrentByteOffset   - Offset into the resource template AML
868  *                                    buffer (to track references to the desc)
869  *
870  * RETURN:      Completed resource node
871  *
872  * DESCRIPTION: Construct a short "StartDependentFn" descriptor
873  *
874  ******************************************************************************/
875
876 ASL_RESOURCE_NODE *
877 RsDoStartDependentDescriptor (
878     ACPI_PARSE_OBJECT       *Op,
879     UINT32                  CurrentByteOffset)
880 {
881     ASL_RESOURCE_DESC       *Descriptor;
882     ACPI_PARSE_OBJECT       *InitializerOp;
883     ASL_RESOURCE_NODE       *Rnode;
884     ASL_RESOURCE_NODE       *PreviousRnode;
885     ASL_RESOURCE_NODE       *NextRnode;
886     UINT32                  i;
887     UINT8                   State;
888
889
890     InitializerOp = Op->Asl.Child;
891     Rnode = RsAllocateResourceNode (sizeof (ASL_START_DEPENDENT_DESC));
892
893     PreviousRnode = Rnode;
894     Descriptor = Rnode->Buffer;
895
896     /* Descriptor has priority byte */
897
898     Descriptor->Std.DescriptorType  = ACPI_RDESC_TYPE_START_DEPENDENT |
899                                         (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
900
901     /*
902      * Process all child initialization nodes
903      */
904     State = ACPI_RSTATE_START_DEPENDENT;
905     for (i = 0; InitializerOp; i++)
906     {
907         switch (i)
908         {
909         case 0: /* Compatibility Priority */
910
911             if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
912             {
913                 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, InitializerOp, NULL);
914             }
915
916             RsSetFlagBits (&Descriptor->Std.Flags, InitializerOp, 0, 0);
917             break;
918
919         case 1: /* Performance/Robustness Priority */
920
921             if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
922             {
923                 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, InitializerOp, NULL);
924             }
925
926             RsSetFlagBits (&Descriptor->Std.Flags, InitializerOp, 2, 0);
927             break;
928
929         default:
930             NextRnode = RsDoOneResourceDescriptor  (InitializerOp, CurrentByteOffset, &State);
931
932             /*
933              * Update current byte offset to indicate the number of bytes from the
934              * start of the buffer.  Buffer can include multiple descriptors, we
935              * must keep track of the offset of not only each descriptor, but each
936              * element (field) within each descriptor as well.
937              */
938
939             CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
940             break;
941         }
942
943         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
944     }
945
946     return (Rnode);
947 }
948
949
950 /*******************************************************************************
951  *
952  * FUNCTION:    RsDoStartDependentNoPriDescriptor
953  *
954  * PARAMETERS:  Op                  - Parent resource descriptor parse node
955  *              CurrentByteOffset   - Offset into the resource template AML
956  *                                    buffer (to track references to the desc)
957  *
958  * RETURN:      Completed resource node
959  *
960  * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
961  *
962  ******************************************************************************/
963
964 ASL_RESOURCE_NODE *
965 RsDoStartDependentNoPriDescriptor (
966     ACPI_PARSE_OBJECT       *Op,
967     UINT32                  CurrentByteOffset)
968 {
969     ASL_RESOURCE_DESC       *Descriptor;
970     ACPI_PARSE_OBJECT       *InitializerOp;
971     ASL_RESOURCE_NODE       *Rnode;
972     ASL_RESOURCE_NODE       *PreviousRnode;
973     ASL_RESOURCE_NODE       *NextRnode;
974     UINT8                   State;
975
976
977     InitializerOp = Op->Asl.Child;
978     Rnode = RsAllocateResourceNode (sizeof (ASL_START_DEPENDENT_NOPRIO_DESC));
979
980     Descriptor = Rnode->Buffer;
981     Descriptor->Std.DescriptorType  = ACPI_RDESC_TYPE_START_DEPENDENT |
982                                         ASL_RDESC_ST_DEPEND_SIZE;
983     PreviousRnode = Rnode;
984
985     /*
986      * Process all child initialization nodes
987      */
988     State = ACPI_RSTATE_START_DEPENDENT;
989     while (InitializerOp)
990     {
991         NextRnode = RsDoOneResourceDescriptor  (InitializerOp, CurrentByteOffset, &State);
992
993         /*
994          * Update current byte offset to indicate the number of bytes from the
995          * start of the buffer.  Buffer can include multiple descriptors, we
996          * must keep track of the offset of not only each descriptor, but each
997          * element (field) within each descriptor as well.
998          */
999
1000         CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
1001
1002         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1003     }
1004
1005     return (Rnode);
1006 }
1007
1008
1009 /*******************************************************************************
1010  *
1011  * FUNCTION:    RsDoVendorSmallDescriptor
1012  *
1013  * PARAMETERS:  Op                  - Parent resource descriptor parse node
1014  *              CurrentByteOffset   - Offset into the resource template AML
1015  *                                    buffer (to track references to the desc)
1016  *
1017  * RETURN:      Completed resource node
1018  *
1019  * DESCRIPTION: Construct a short "VendorShort" descriptor
1020  *
1021  ******************************************************************************/
1022
1023 ASL_RESOURCE_NODE *
1024 RsDoVendorSmallDescriptor (
1025     ACPI_PARSE_OBJECT       *Op,
1026     UINT32                  CurrentByteOffset)
1027 {
1028     ASL_RESOURCE_DESC       *Descriptor;
1029     ACPI_PARSE_OBJECT       *InitializerOp;
1030     ASL_RESOURCE_NODE       *Rnode;
1031     UINT32                  i;
1032
1033
1034     InitializerOp = Op->Asl.Child;
1035     Rnode = RsAllocateResourceNode (sizeof (ASL_SMALL_VENDOR_DESC));
1036
1037     Descriptor = Rnode->Buffer;
1038     Descriptor->Smv.DescriptorType  = ACPI_RDESC_TYPE_SMALL_VENDOR;
1039
1040     /*
1041      * Process all child initialization nodes
1042      */
1043     InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1044     for (i = 0; InitializerOp; i++)
1045     {
1046         /* Maximum 7 vendor data bytes allowed (0-6) */
1047
1048         if (i >= 7)
1049         {
1050             AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
1051
1052             /* Eat the excess initializers */
1053
1054             while (InitializerOp)
1055             {
1056                 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1057             }
1058             break;
1059         }
1060
1061         Descriptor->Smv.VendorDefined[i] = (UINT8) InitializerOp->Asl.Value.Integer;
1062         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1063     }
1064
1065     /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
1066
1067     Rnode->BufferLength -= (7 - i);
1068
1069     /* Set the length in the Type Tag */
1070
1071     Descriptor->Smv.DescriptorType |= (UINT8) i;
1072     return (Rnode);
1073 }
1074
1075