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