aslrestype2d.c revision 213806
1
2/******************************************************************************
3 *
4 * Module Name: aslrestype2d - Large DWord address resource descriptors
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights.  You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code.  No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision.  In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change.  Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee.  Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution.  In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government.  In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118#include <contrib/dev/acpica/compiler/aslcompiler.h>
119#include "aslcompiler.y.h"
120
121#define _COMPONENT          ACPI_COMPILER
122        ACPI_MODULE_NAME    ("aslrestype2d")
123
124/*
125 * This module contains the Dword (32-bit) address space descriptors:
126 *
127 * DwordIO
128 * DwordMemory
129 * DwordSpace
130 */
131
132/*******************************************************************************
133 *
134 * FUNCTION:    RsDoDwordIoDescriptor
135 *
136 * PARAMETERS:  Op                  - Parent resource descriptor parse node
137 *              CurrentByteOffset   - Offset into the resource template AML
138 *                                    buffer (to track references to the desc)
139 *
140 * RETURN:      Completed resource node
141 *
142 * DESCRIPTION: Construct a long "DwordIO" descriptor
143 *
144 ******************************************************************************/
145
146ASL_RESOURCE_NODE *
147RsDoDwordIoDescriptor (
148    ACPI_PARSE_OBJECT       *Op,
149    UINT32                  CurrentByteOffset)
150{
151    AML_RESOURCE            *Descriptor;
152    ACPI_PARSE_OBJECT       *InitializerOp;
153    ACPI_PARSE_OBJECT       *MinOp = NULL;
154    ACPI_PARSE_OBJECT       *MaxOp = NULL;
155    ACPI_PARSE_OBJECT       *LengthOp = NULL;
156    ACPI_PARSE_OBJECT       *GranOp = NULL;
157    ASL_RESOURCE_NODE       *Rnode;
158    UINT16                  StringLength = 0;
159    UINT32                  OptionIndex = 0;
160    UINT8                   *OptionalFields;
161    UINT32                  i;
162    BOOLEAN                 ResSourceIndex = FALSE;
163
164
165    InitializerOp = Op->Asl.Child;
166    StringLength = RsGetStringDataLength (InitializerOp);
167
168    Rnode = RsAllocateResourceNode (
169                sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength);
170
171    Descriptor = Rnode->Buffer;
172    Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32;
173    Descriptor->Address32.ResourceType   = ACPI_ADDRESS_TYPE_IO_RANGE;
174
175    /*
176     * Initial descriptor length -- may be enlarged if there are
177     * optional fields present
178     */
179    OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
180    Descriptor->Address32.ResourceLength = (UINT16)
181        (sizeof (AML_RESOURCE_ADDRESS32) -
182         sizeof (AML_RESOURCE_LARGE_HEADER));
183
184    /* Process all child initialization nodes */
185
186    for (i = 0; InitializerOp; i++)
187    {
188        switch (i)
189        {
190        case 0: /* Resource Usage */
191
192            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1);
193            break;
194
195        case 1: /* MinType */
196
197            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0);
198            RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
199                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2);
200            break;
201
202        case 2: /* MaxType */
203
204            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0);
205            RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
206                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3);
207            break;
208
209        case 3: /* DecodeType */
210
211            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0);
212            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
213                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1);
214            break;
215
216        case 4: /* Range Type */
217
218            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 3);
219            RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
220                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0);
221            break;
222
223        case 5: /* Address Granularity */
224
225            Descriptor->Address32.Granularity =
226                (UINT32) InitializerOp->Asl.Value.Integer;
227            RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY,
228                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
229            GranOp = InitializerOp;
230            break;
231
232        case 6: /* Address Min */
233
234            Descriptor->Address32.Minimum =
235                (UINT32) InitializerOp->Asl.Value.Integer;
236            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
237                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
238            MinOp = InitializerOp;
239            break;
240
241        case 7: /* Address Max */
242
243            Descriptor->Address32.Maximum =
244                (UINT32) InitializerOp->Asl.Value.Integer;
245            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
246                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
247            MaxOp = InitializerOp;
248            break;
249
250        case 8: /* Translation Offset */
251
252            Descriptor->Address32.TranslationOffset =
253                (UINT32) InitializerOp->Asl.Value.Integer;
254            RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
255                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
256            break;
257
258        case 9: /* Address Length */
259
260            Descriptor->Address32.AddressLength =
261                (UINT32) InitializerOp->Asl.Value.Integer;
262            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
263                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
264            LengthOp = InitializerOp;
265            break;
266
267        case 10: /* ResSourceIndex [Optional Field - BYTE] */
268
269            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
270            {
271                /* Found a valid ResourceSourceIndex */
272
273                OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
274                OptionIndex++;
275                Descriptor->Address32.ResourceLength++;
276                ResSourceIndex = TRUE;
277            }
278            break;
279
280        case 11: /* ResSource [Optional Field - STRING] */
281
282            if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
283                (InitializerOp->Asl.Value.String))
284            {
285                if (StringLength)
286                {
287                    /* Found a valid ResourceSource */
288
289                    Descriptor->Address32.ResourceLength = (UINT16)
290                        (Descriptor->Address32.ResourceLength + StringLength);
291
292                    strcpy ((char *)
293                        &OptionalFields[OptionIndex],
294                        InitializerOp->Asl.Value.String);
295
296                    /* ResourceSourceIndex must also be valid */
297
298                    if (!ResSourceIndex)
299                    {
300                        AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
301                            InitializerOp, NULL);
302                    }
303                }
304            }
305
306#if 0
307            /*
308             * Not a valid ResourceSource, ResourceSourceIndex must also
309             * be invalid
310             */
311            else if (ResSourceIndex)
312            {
313                AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
314                    InitializerOp, NULL);
315            }
316#endif
317            break;
318
319        case 12: /* ResourceTag */
320
321            UtAttachNamepathToOwner (Op, InitializerOp);
322            break;
323
324        case 13: /* Type */
325
326            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 4, 0);
327            RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
328                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 4);
329            break;
330
331        case 14: /* Translation Type */
332
333            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0);
334            RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
335                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5);
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    /* Validate the Min/Max/Len/Gran values */
348
349    RsLargeAddressCheck (
350        (UINT64) Descriptor->Address32.Minimum,
351        (UINT64) Descriptor->Address32.Maximum,
352        (UINT64) Descriptor->Address32.AddressLength,
353        (UINT64) Descriptor->Address32.Granularity,
354        Descriptor->Address32.Flags,
355        MinOp, MaxOp, LengthOp, GranOp, Op);
356
357    Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
358                            OptionIndex + StringLength;
359    return (Rnode);
360}
361
362
363/*******************************************************************************
364 *
365 * FUNCTION:    RsDoDwordMemoryDescriptor
366 *
367 * PARAMETERS:  Op                  - Parent resource descriptor parse node
368 *              CurrentByteOffset   - Offset into the resource template AML
369 *                                    buffer (to track references to the desc)
370 *
371 * RETURN:      Completed resource node
372 *
373 * DESCRIPTION: Construct a long "DwordMemory" descriptor
374 *
375 ******************************************************************************/
376
377ASL_RESOURCE_NODE *
378RsDoDwordMemoryDescriptor (
379    ACPI_PARSE_OBJECT       *Op,
380    UINT32                  CurrentByteOffset)
381{
382    AML_RESOURCE            *Descriptor;
383    ACPI_PARSE_OBJECT       *InitializerOp;
384    ACPI_PARSE_OBJECT       *MinOp = NULL;
385    ACPI_PARSE_OBJECT       *MaxOp = NULL;
386    ACPI_PARSE_OBJECT       *LengthOp = NULL;
387    ACPI_PARSE_OBJECT       *GranOp = NULL;
388    ASL_RESOURCE_NODE       *Rnode;
389    UINT8                   *OptionalFields;
390    UINT16                  StringLength = 0;
391    UINT32                  OptionIndex = 0;
392    UINT32                  i;
393    BOOLEAN                 ResSourceIndex = FALSE;
394
395
396    InitializerOp = Op->Asl.Child;
397    StringLength = RsGetStringDataLength (InitializerOp);
398
399    Rnode = RsAllocateResourceNode (
400                sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength);
401
402    Descriptor = Rnode->Buffer;
403    Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32;
404    Descriptor->Address32.ResourceType   = ACPI_ADDRESS_TYPE_MEMORY_RANGE;
405
406    /*
407     * Initial descriptor length -- may be enlarged if there are
408     * optional fields present
409     */
410    OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
411    Descriptor->Address32.ResourceLength = (UINT16)
412        (sizeof (AML_RESOURCE_ADDRESS32) -
413         sizeof (AML_RESOURCE_LARGE_HEADER));
414
415
416    /* Process all child initialization nodes */
417
418    for (i = 0; InitializerOp; i++)
419    {
420        switch (i)
421        {
422        case 0: /* Resource Usage */
423
424            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1);
425            break;
426
427        case 1: /* DecodeType */
428
429            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0);
430            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
431                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1);
432            break;
433
434        case 2: /* MinType */
435
436            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0);
437            RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
438                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2);
439            break;
440
441        case 3: /* MaxType */
442
443            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0);
444            RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
445                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3);
446            break;
447
448        case 4: /* Memory Type */
449
450            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 1, 0);
451            RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE,
452                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 1);
453            break;
454
455        case 5: /* Read/Write Type */
456
457            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 1);
458            RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
459                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0);
460            break;
461
462        case 6: /* Address Granularity */
463
464            Descriptor->Address32.Granularity =
465                (UINT32) InitializerOp->Asl.Value.Integer;
466            RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY,
467                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
468            GranOp = InitializerOp;
469            break;
470
471        case 7: /* Min Address */
472
473            Descriptor->Address32.Minimum =
474                (UINT32) InitializerOp->Asl.Value.Integer;
475            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
476                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
477            MinOp = InitializerOp;
478            break;
479
480        case 8: /* Max Address */
481
482            Descriptor->Address32.Maximum =
483                (UINT32) InitializerOp->Asl.Value.Integer;
484            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
485                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
486            MaxOp = InitializerOp;
487            break;
488
489        case 9: /* Translation Offset */
490
491            Descriptor->Address32.TranslationOffset =
492                (UINT32) InitializerOp->Asl.Value.Integer;
493            RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
494                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
495            break;
496
497        case 10: /* Address Length */
498
499            Descriptor->Address32.AddressLength =
500                (UINT32) InitializerOp->Asl.Value.Integer;
501            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
502                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
503            LengthOp = InitializerOp;
504            break;
505
506        case 11: /* ResSourceIndex [Optional Field - BYTE] */
507
508            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
509            {
510                OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
511                OptionIndex++;
512                Descriptor->Address32.ResourceLength++;
513                ResSourceIndex = TRUE;
514            }
515            break;
516
517        case 12: /* ResSource [Optional Field - STRING] */
518
519            if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
520                (InitializerOp->Asl.Value.String))
521            {
522                if (StringLength)
523                {
524                    Descriptor->Address32.ResourceLength = (UINT16)
525                        (Descriptor->Address32.ResourceLength + StringLength);
526
527                    strcpy ((char *)
528                        &OptionalFields[OptionIndex],
529                        InitializerOp->Asl.Value.String);
530
531                    /* ResourceSourceIndex must also be valid */
532
533                    if (!ResSourceIndex)
534                    {
535                        AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
536                            InitializerOp, NULL);
537                    }
538                }
539            }
540
541#if 0
542            /*
543             * Not a valid ResourceSource, ResourceSourceIndex must also
544             * be invalid
545             */
546            else if (ResSourceIndex)
547            {
548                AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
549                    InitializerOp, NULL);
550            }
551#endif
552            break;
553
554        case 13: /* ResourceTag */
555
556            UtAttachNamepathToOwner (Op, InitializerOp);
557            break;
558
559
560        case 14: /* Address Range */
561
562            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 3, 0);
563            RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES,
564                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 3);
565            break;
566
567        case 15: /* Type */
568
569            RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0);
570            RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
571                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5);
572            break;
573
574        default:
575
576            AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
577            break;
578        }
579
580        InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
581    }
582
583    /* Validate the Min/Max/Len/Gran values */
584
585    RsLargeAddressCheck (
586        (UINT64) Descriptor->Address32.Minimum,
587        (UINT64) Descriptor->Address32.Maximum,
588        (UINT64) Descriptor->Address32.AddressLength,
589        (UINT64) Descriptor->Address32.Granularity,
590        Descriptor->Address32.Flags,
591        MinOp, MaxOp, LengthOp, GranOp, Op);
592
593    Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
594                            OptionIndex + StringLength;
595    return (Rnode);
596}
597
598
599/*******************************************************************************
600 *
601 * FUNCTION:    RsDoDwordSpaceDescriptor
602 *
603 * PARAMETERS:  Op                  - Parent resource descriptor parse node
604 *              CurrentByteOffset   - Offset into the resource template AML
605 *                                    buffer (to track references to the desc)
606 *
607 * RETURN:      Completed resource node
608 *
609 * DESCRIPTION: Construct a long "DwordSpace" descriptor
610 *
611 ******************************************************************************/
612
613ASL_RESOURCE_NODE *
614RsDoDwordSpaceDescriptor (
615    ACPI_PARSE_OBJECT       *Op,
616    UINT32                  CurrentByteOffset)
617{
618    AML_RESOURCE            *Descriptor;
619    ACPI_PARSE_OBJECT       *InitializerOp;
620    ACPI_PARSE_OBJECT       *MinOp = NULL;
621    ACPI_PARSE_OBJECT       *MaxOp = NULL;
622    ACPI_PARSE_OBJECT       *LengthOp = NULL;
623    ACPI_PARSE_OBJECT       *GranOp = NULL;
624    ASL_RESOURCE_NODE       *Rnode;
625    UINT8                   *OptionalFields;
626    UINT16                  StringLength = 0;
627    UINT32                  OptionIndex = 0;
628    UINT32                  i;
629    BOOLEAN                 ResSourceIndex = FALSE;
630
631
632    InitializerOp = Op->Asl.Child;
633    StringLength = RsGetStringDataLength (InitializerOp);
634
635    Rnode = RsAllocateResourceNode (
636                sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength);
637
638    Descriptor = Rnode->Buffer;
639    Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32;
640
641    /*
642     * Initial descriptor length -- may be enlarged if there are
643     * optional fields present
644     */
645    OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
646    Descriptor->Address32.ResourceLength = (UINT16)
647        (sizeof (AML_RESOURCE_ADDRESS32) -
648         sizeof (AML_RESOURCE_LARGE_HEADER));
649
650    /* Process all child initialization nodes */
651
652    for (i = 0; InitializerOp; i++)
653    {
654        switch (i)
655        {
656        case 0: /* Resource Type */
657
658            Descriptor->Address32.ResourceType =
659                (UINT8) InitializerOp->Asl.Value.Integer;
660            break;
661
662        case 1: /* Resource Usage */
663
664            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1);
665            break;
666
667        case 2: /* DecodeType */
668
669            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0);
670            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
671                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1);
672            break;
673
674        case 3: /* MinType */
675
676            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0);
677            RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
678                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2);
679            break;
680
681        case 4: /* MaxType */
682
683            RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0);
684            RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
685                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3);
686            break;
687
688        case 5: /* Type-Specific flags */
689
690            Descriptor->Address32.SpecificFlags =
691                (UINT8) InitializerOp->Asl.Value.Integer;
692            break;
693
694        case 6: /* Address Granularity */
695
696            Descriptor->Address32.Granularity =
697                (UINT32) InitializerOp->Asl.Value.Integer;
698            RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY,
699                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
700            GranOp = InitializerOp;
701            break;
702
703        case 7: /* Min Address */
704
705            Descriptor->Address32.Minimum =
706                (UINT32) InitializerOp->Asl.Value.Integer;
707            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
708                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
709            MinOp = InitializerOp;
710            break;
711
712        case 8: /* Max Address */
713
714            Descriptor->Address32.Maximum =
715                (UINT32) InitializerOp->Asl.Value.Integer;
716            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
717                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
718            MaxOp = InitializerOp;
719            break;
720
721        case 9: /* Translation Offset */
722
723            Descriptor->Address32.TranslationOffset =
724                (UINT32) InitializerOp->Asl.Value.Integer;
725            RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
726                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
727            break;
728
729        case 10: /* Address Length */
730
731            Descriptor->Address32.AddressLength =
732                (UINT32) InitializerOp->Asl.Value.Integer;
733            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
734                CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
735            LengthOp = InitializerOp;
736            break;
737
738        case 11: /* ResSourceIndex [Optional Field - BYTE] */
739
740            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
741            {
742                OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
743                OptionIndex++;
744                Descriptor->Address32.ResourceLength++;
745                ResSourceIndex = TRUE;
746            }
747            break;
748
749        case 12: /* ResSource [Optional Field - STRING] */
750
751            if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
752                (InitializerOp->Asl.Value.String))
753            {
754                if (StringLength)
755                {
756                    Descriptor->Address32.ResourceLength = (UINT16)
757                        (Descriptor->Address32.ResourceLength + StringLength);
758
759                    strcpy ((char *)
760                        &OptionalFields[OptionIndex],
761                        InitializerOp->Asl.Value.String);
762
763                    /* ResourceSourceIndex must also be valid */
764
765                    if (!ResSourceIndex)
766                    {
767                        AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
768                            InitializerOp, NULL);
769                    }
770                }
771            }
772
773#if 0
774            /*
775             * Not a valid ResourceSource, ResourceSourceIndex must also
776             * be invalid
777             */
778            else if (ResSourceIndex)
779            {
780                AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
781                    InitializerOp, NULL);
782            }
783#endif
784            break;
785
786        case 13: /* ResourceTag */
787
788            UtAttachNamepathToOwner (Op, InitializerOp);
789            break;
790
791        default:
792
793            AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST,
794                InitializerOp, NULL);
795            break;
796        }
797
798        InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
799    }
800
801    /* Validate the Min/Max/Len/Gran values */
802
803    RsLargeAddressCheck (
804        (UINT64) Descriptor->Address32.Minimum,
805        (UINT64) Descriptor->Address32.Maximum,
806        (UINT64) Descriptor->Address32.AddressLength,
807        (UINT64) Descriptor->Address32.Granularity,
808        Descriptor->Address32.Flags,
809        MinOp, MaxOp, LengthOp, GranOp, Op);
810
811    Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
812                            OptionIndex + StringLength;
813    return (Rnode);
814}
815