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