aslrestype2q.c revision 213806
1
2/******************************************************************************
3 *
4 * Module Name: aslrestype2q - Large QWord 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    ("aslrestype2q")
123
124/*
125 * This module contains the QWord (64-bit) address space descriptors:
126 *
127 * QWordIO
128 * QWordMemory
129 * QWordSpace
130 */
131
132/*******************************************************************************
133 *
134 * FUNCTION:    RsDoQwordIoDescriptor
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 "QwordIO" descriptor
143 *
144 ******************************************************************************/
145
146ASL_RESOURCE_NODE *
147RsDoQwordIoDescriptor (
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    UINT8                   *OptionalFields;
159    UINT16                  StringLength = 0;
160    UINT32                  OptionIndex = 0;
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_ADDRESS64) + 1 + StringLength);
170
171    Descriptor = Rnode->Buffer;
172    Descriptor->Address64.DescriptorType  = ACPI_RESOURCE_NAME_ADDRESS64;
173    Descriptor->Address64.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_ADDRESS64);
180    Descriptor->Address64.ResourceLength = (UINT16)
181        (sizeof (AML_RESOURCE_ADDRESS64) -
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->Address64.Flags, InitializerOp, 0, 1);
193            break;
194
195        case 1: /* MinType */
196
197            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0);
198            RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
199                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2);
200            break;
201
202        case 2: /* MaxType */
203
204            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0);
205            RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
206                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3);
207            break;
208
209        case 3: /* DecodeType */
210
211            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0);
212            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
213                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1);
214            break;
215
216        case 4: /* Range Type */
217
218            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3);
219            RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
220                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0);
221            break;
222
223        case 5: /* Address Granularity */
224
225            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
226            RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY,
227                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
228            GranOp = InitializerOp;
229            break;
230
231        case 6: /* Address Min */
232
233            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
234            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
235                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
236            MinOp = InitializerOp;
237            break;
238
239        case 7: /* Address Max */
240
241            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
242            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
243                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
244            MaxOp = InitializerOp;
245            break;
246
247        case 8: /* Translation Offset */
248
249            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
250            RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
251                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
252            break;
253
254        case 9: /* Address Length */
255
256            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
257            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
258                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
259            LengthOp = InitializerOp;
260            break;
261
262        case 10: /* ResSourceIndex [Optional Field - BYTE] */
263
264            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
265            {
266                OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
267                OptionIndex++;
268                Descriptor->Address64.ResourceLength++;
269                ResSourceIndex = TRUE;
270            }
271            break;
272
273        case 11: /* ResSource [Optional Field - STRING] */
274
275            if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
276                (InitializerOp->Asl.Value.String))
277            {
278                if (StringLength)
279                {
280                    Descriptor->Address64.ResourceLength = (UINT16)
281                        (Descriptor->Address64.ResourceLength + StringLength);
282
283                    strcpy ((char *)
284                        &OptionalFields[OptionIndex],
285                        InitializerOp->Asl.Value.String);
286
287                    /* ResourceSourceIndex must also be valid */
288
289                    if (!ResSourceIndex)
290                    {
291                        AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
292                            InitializerOp, NULL);
293                    }
294                }
295            }
296
297#if 0
298            /*
299             * Not a valid ResourceSource, ResourceSourceIndex must also
300             * be invalid
301             */
302            else if (ResSourceIndex)
303            {
304                AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
305                    InitializerOp, NULL);
306            }
307#endif
308            break;
309
310        case 12: /* ResourceTag */
311
312            UtAttachNamepathToOwner (Op, InitializerOp);
313            break;
314
315        case 13: /* Type */
316
317            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0);
318            RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
319                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4);
320            break;
321
322        case 14: /* Translation Type */
323
324            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0);
325            RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
326                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5);
327            break;
328
329        default:
330
331            AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
332            break;
333        }
334
335        InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
336    }
337
338    /* Validate the Min/Max/Len/Gran values */
339
340    RsLargeAddressCheck (
341        Descriptor->Address64.Minimum,
342        Descriptor->Address64.Maximum,
343        Descriptor->Address64.AddressLength,
344        Descriptor->Address64.Granularity,
345        Descriptor->Address64.Flags,
346        MinOp, MaxOp, LengthOp, GranOp, Op);
347
348    Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
349                            OptionIndex + StringLength;
350    return (Rnode);
351}
352
353
354/*******************************************************************************
355 *
356 * FUNCTION:    RsDoQwordMemoryDescriptor
357 *
358 * PARAMETERS:  Op                  - Parent resource descriptor parse node
359 *              CurrentByteOffset   - Offset into the resource template AML
360 *                                    buffer (to track references to the desc)
361 *
362 * RETURN:      Completed resource node
363 *
364 * DESCRIPTION: Construct a long "QwordMemory" descriptor
365 *
366 ******************************************************************************/
367
368ASL_RESOURCE_NODE *
369RsDoQwordMemoryDescriptor (
370    ACPI_PARSE_OBJECT       *Op,
371    UINT32                  CurrentByteOffset)
372{
373    AML_RESOURCE            *Descriptor;
374    ACPI_PARSE_OBJECT       *InitializerOp;
375    ACPI_PARSE_OBJECT       *MinOp = NULL;
376    ACPI_PARSE_OBJECT       *MaxOp = NULL;
377    ACPI_PARSE_OBJECT       *LengthOp = NULL;
378    ACPI_PARSE_OBJECT       *GranOp = NULL;
379    ASL_RESOURCE_NODE       *Rnode;
380    UINT8                   *OptionalFields;
381    UINT16                  StringLength = 0;
382    UINT32                  OptionIndex = 0;
383    UINT32                  i;
384    BOOLEAN                 ResSourceIndex = FALSE;
385
386
387    InitializerOp = Op->Asl.Child;
388    StringLength = RsGetStringDataLength (InitializerOp);
389
390    Rnode = RsAllocateResourceNode (
391                sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength);
392
393    Descriptor = Rnode->Buffer;
394    Descriptor->Address64.DescriptorType  = ACPI_RESOURCE_NAME_ADDRESS64;
395    Descriptor->Address64.ResourceType    = ACPI_ADDRESS_TYPE_MEMORY_RANGE;
396
397    /*
398     * Initial descriptor length -- may be enlarged if there are
399     * optional fields present
400     */
401    OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
402    Descriptor->Address64.ResourceLength = (UINT16)
403        (sizeof (AML_RESOURCE_ADDRESS64) -
404         sizeof (AML_RESOURCE_LARGE_HEADER));
405
406    /* Process all child initialization nodes */
407
408    for (i = 0; InitializerOp; i++)
409    {
410        switch (i)
411        {
412        case 0: /* Resource Usage */
413
414            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1);
415            break;
416
417        case 1: /* DecodeType */
418
419            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0);
420            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
421                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1);
422            break;
423
424        case 2: /* MinType */
425
426            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0);
427            RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
428                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2);
429            break;
430
431        case 3: /* MaxType */
432
433            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0);
434            RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
435                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3);
436            break;
437
438        case 4: /* Memory Type */
439
440            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0);
441            RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE,
442                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1);
443            break;
444
445        case 5: /* Read/Write Type */
446
447            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1);
448            RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
449                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0);
450            break;
451
452        case 6: /* Address Granularity */
453
454            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
455            RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY,
456                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
457            GranOp = InitializerOp;
458            break;
459
460        case 7: /* Min Address */
461
462            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
463            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
464                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
465            MinOp = InitializerOp;
466            break;
467
468        case 8: /* Max Address */
469
470            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
471            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
472                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
473            MaxOp = InitializerOp;
474            break;
475
476        case 9: /* Translation Offset */
477
478            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
479            RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
480                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
481            break;
482
483        case 10: /* Address Length */
484
485            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
486            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
487                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
488            LengthOp = InitializerOp;
489            break;
490
491        case 11: /* ResSourceIndex [Optional Field - BYTE] */
492
493            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
494            {
495                OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
496                OptionIndex++;
497                Descriptor->Address64.ResourceLength++;
498                ResSourceIndex = TRUE;
499            }
500            break;
501
502        case 12: /* ResSource [Optional Field - STRING] */
503
504            if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
505                (InitializerOp->Asl.Value.String))
506            {
507                if (StringLength)
508                {
509                    Descriptor->Address64.ResourceLength = (UINT16)
510                        (Descriptor->Address64.ResourceLength + StringLength);
511
512                    strcpy ((char *)
513                        &OptionalFields[OptionIndex],
514                        InitializerOp->Asl.Value.String);
515
516                    /* ResourceSourceIndex must also be valid */
517
518                    if (!ResSourceIndex)
519                    {
520                        AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
521                            InitializerOp, NULL);
522                    }
523                }
524            }
525
526#if 0
527            /*
528             * Not a valid ResourceSource, ResourceSourceIndex must also
529             * be invalid
530             */
531            else if (ResSourceIndex)
532            {
533                AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
534                    InitializerOp, NULL);
535            }
536#endif
537            break;
538
539        case 13: /* ResourceTag */
540
541            UtAttachNamepathToOwner (Op, InitializerOp);
542            break;
543
544
545        case 14: /* Address Range */
546
547            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0);
548            RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES,
549                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3);
550            break;
551
552        case 15: /* Type */
553
554            RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0);
555            RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
556                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5);
557            break;
558
559        default:
560
561            AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
562            break;
563        }
564
565        InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
566    }
567
568    /* Validate the Min/Max/Len/Gran values */
569
570    RsLargeAddressCheck (
571        Descriptor->Address64.Minimum,
572        Descriptor->Address64.Maximum,
573        Descriptor->Address64.AddressLength,
574        Descriptor->Address64.Granularity,
575        Descriptor->Address64.Flags,
576        MinOp, MaxOp, LengthOp, GranOp, Op);
577
578    Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
579                            OptionIndex + StringLength;
580    return (Rnode);
581}
582
583
584/*******************************************************************************
585 *
586 * FUNCTION:    RsDoQwordSpaceDescriptor
587 *
588 * PARAMETERS:  Op                  - Parent resource descriptor parse node
589 *              CurrentByteOffset   - Offset into the resource template AML
590 *                                    buffer (to track references to the desc)
591 *
592 * RETURN:      Completed resource node
593 *
594 * DESCRIPTION: Construct a long "QwordSpace" descriptor
595 *
596 ******************************************************************************/
597
598ASL_RESOURCE_NODE *
599RsDoQwordSpaceDescriptor (
600    ACPI_PARSE_OBJECT       *Op,
601    UINT32                  CurrentByteOffset)
602{
603    AML_RESOURCE            *Descriptor;
604    ACPI_PARSE_OBJECT       *InitializerOp;
605    ACPI_PARSE_OBJECT       *MinOp = NULL;
606    ACPI_PARSE_OBJECT       *MaxOp = NULL;
607    ACPI_PARSE_OBJECT       *LengthOp = NULL;
608    ACPI_PARSE_OBJECT       *GranOp = NULL;
609    ASL_RESOURCE_NODE       *Rnode;
610    UINT8                   *OptionalFields;
611    UINT16                  StringLength = 0;
612    UINT32                  OptionIndex = 0;
613    UINT32                  i;
614    BOOLEAN                 ResSourceIndex = FALSE;
615
616
617    InitializerOp = Op->Asl.Child;
618    StringLength = RsGetStringDataLength (InitializerOp);
619
620    Rnode = RsAllocateResourceNode (
621                sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength);
622
623    Descriptor = Rnode->Buffer;
624    Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64;
625
626    /*
627     * Initial descriptor length -- may be enlarged if there are
628     * optional fields present
629     */
630    OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
631    Descriptor->Address64.ResourceLength = (UINT16)
632        (sizeof (AML_RESOURCE_ADDRESS64) -
633         sizeof (AML_RESOURCE_LARGE_HEADER));
634
635    /* Process all child initialization nodes */
636
637    for (i = 0; InitializerOp; i++)
638    {
639        switch (i)
640        {
641        case 0: /* Resource Type */
642
643            Descriptor->Address64.ResourceType =
644                (UINT8) InitializerOp->Asl.Value.Integer;
645            break;
646
647        case 1: /* Resource Usage */
648
649            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1);
650            break;
651
652        case 2: /* DecodeType */
653
654            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0);
655            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
656                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1);
657            break;
658
659        case 3: /* MinType */
660
661            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0);
662            RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
663                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2);
664            break;
665
666        case 4: /* MaxType */
667
668            RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0);
669            RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
670                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3);
671            break;
672
673        case 5: /* Type-Specific flags */
674
675            Descriptor->Address64.SpecificFlags =
676                (UINT8) InitializerOp->Asl.Value.Integer;
677            break;
678
679        case 6: /* Address Granularity */
680
681            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
682            RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY,
683                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
684            GranOp = InitializerOp;
685            break;
686
687        case 7: /* Min Address */
688
689            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
690            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
691                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
692            MinOp = InitializerOp;
693            break;
694
695        case 8: /* Max Address */
696
697            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
698            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
699                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
700            MaxOp = InitializerOp;
701            break;
702
703        case 9: /* Translation Offset */
704
705            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
706            RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
707                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
708            break;
709
710        case 10: /* Address Length */
711
712            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
713            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
714                CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
715            LengthOp = InitializerOp;
716            break;
717
718        case 11: /* ResSourceIndex [Optional Field - BYTE] */
719
720            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
721            {
722                OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
723                OptionIndex++;
724                Descriptor->Address64.ResourceLength++;
725                ResSourceIndex = TRUE;
726            }
727            break;
728
729        case 12: /* ResSource [Optional Field - STRING] */
730
731            if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
732                (InitializerOp->Asl.Value.String))
733            {
734                if (StringLength)
735                {
736                    Descriptor->Address64.ResourceLength = (UINT16)
737                        (Descriptor->Address64.ResourceLength + StringLength);
738
739                    strcpy ((char *)
740                        &OptionalFields[OptionIndex],
741                        InitializerOp->Asl.Value.String);
742
743                    /* ResourceSourceIndex must also be valid */
744
745                    if (!ResSourceIndex)
746                    {
747                        AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
748                            InitializerOp, NULL);
749                    }
750                }
751            }
752
753#if 0
754            /*
755             * Not a valid ResourceSource, ResourceSourceIndex must also
756             * be invalid
757             */
758            else if (ResSourceIndex)
759            {
760                AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
761                    InitializerOp, NULL);
762            }
763#endif
764            break;
765
766        case 13: /* ResourceTag */
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    /* Validate the Min/Max/Len/Gran values */
781
782    RsLargeAddressCheck (
783        Descriptor->Address64.Minimum,
784        Descriptor->Address64.Maximum,
785        Descriptor->Address64.AddressLength,
786        Descriptor->Address64.Granularity,
787        Descriptor->Address64.Flags,
788        MinOp, MaxOp, LengthOp, GranOp, Op);
789
790    Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
791                            OptionIndex + StringLength;
792    return (Rnode);
793}
794