OSDN Git Service

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