]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/compiler/dttable2.c
Merge ACPICA 20170929.
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / compiler / dttable2.c
1 /******************************************************************************
2  *
3  * Module Name: dttable2.c - handling for specific ACPI tables
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2017, 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  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151
152 /* Compile all complex data tables, signatures starting with L-Z */
153
154 #include <contrib/dev/acpica/compiler/aslcompiler.h>
155
156 #define _COMPONENT          DT_COMPILER
157         ACPI_MODULE_NAME    ("dttable2")
158
159
160 /******************************************************************************
161  *
162  * FUNCTION:    DtCompileLpit
163  *
164  * PARAMETERS:  List                - Current field list pointer
165  *
166  * RETURN:      Status
167  *
168  * DESCRIPTION: Compile LPIT.
169  *
170  *****************************************************************************/
171
172 ACPI_STATUS
173 DtCompileLpit (
174     void                    **List)
175 {
176     ACPI_STATUS             Status;
177     DT_SUBTABLE             *Subtable;
178     DT_SUBTABLE             *ParentTable;
179     DT_FIELD                **PFieldList = (DT_FIELD **) List;
180     DT_FIELD                *SubtableStart;
181     ACPI_DMTABLE_INFO       *InfoTable;
182     ACPI_LPIT_HEADER        *LpitHeader;
183
184
185     /* Note: Main table consists only of the standard ACPI table header */
186
187     while (*PFieldList)
188     {
189         SubtableStart = *PFieldList;
190
191         /* LPIT Subtable header */
192
193         Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr,
194             &Subtable, TRUE);
195         if (ACPI_FAILURE (Status))
196         {
197             return (Status);
198         }
199
200         ParentTable = DtPeekSubtable ();
201         DtInsertSubtable (ParentTable, Subtable);
202         DtPushSubtable (Subtable);
203
204         LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer);
205
206         switch (LpitHeader->Type)
207         {
208         case ACPI_LPIT_TYPE_NATIVE_CSTATE:
209
210             InfoTable = AcpiDmTableInfoLpit0;
211             break;
212
213         default:
214
215             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT");
216             return (AE_ERROR);
217         }
218
219         /* LPIT Subtable */
220
221         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
222         if (ACPI_FAILURE (Status))
223         {
224             return (Status);
225         }
226
227         ParentTable = DtPeekSubtable ();
228         DtInsertSubtable (ParentTable, Subtable);
229         DtPopSubtable ();
230     }
231
232     return (AE_OK);
233 }
234
235
236 /******************************************************************************
237  *
238  * FUNCTION:    DtCompileMadt
239  *
240  * PARAMETERS:  List                - Current field list pointer
241  *
242  * RETURN:      Status
243  *
244  * DESCRIPTION: Compile MADT.
245  *
246  *****************************************************************************/
247
248 ACPI_STATUS
249 DtCompileMadt (
250     void                    **List)
251 {
252     ACPI_STATUS             Status;
253     DT_SUBTABLE             *Subtable;
254     DT_SUBTABLE             *ParentTable;
255     DT_FIELD                **PFieldList = (DT_FIELD **) List;
256     DT_FIELD                *SubtableStart;
257     ACPI_SUBTABLE_HEADER    *MadtHeader;
258     ACPI_DMTABLE_INFO       *InfoTable;
259
260
261     Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt,
262         &Subtable, TRUE);
263     if (ACPI_FAILURE (Status))
264     {
265         return (Status);
266     }
267
268     ParentTable = DtPeekSubtable ();
269     DtInsertSubtable (ParentTable, Subtable);
270
271     while (*PFieldList)
272     {
273         SubtableStart = *PFieldList;
274         Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr,
275             &Subtable, TRUE);
276         if (ACPI_FAILURE (Status))
277         {
278             return (Status);
279         }
280
281         ParentTable = DtPeekSubtable ();
282         DtInsertSubtable (ParentTable, Subtable);
283         DtPushSubtable (Subtable);
284
285         MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
286
287         switch (MadtHeader->Type)
288         {
289         case ACPI_MADT_TYPE_LOCAL_APIC:
290
291             InfoTable = AcpiDmTableInfoMadt0;
292             break;
293
294         case ACPI_MADT_TYPE_IO_APIC:
295
296             InfoTable = AcpiDmTableInfoMadt1;
297             break;
298
299         case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
300
301             InfoTable = AcpiDmTableInfoMadt2;
302             break;
303
304         case ACPI_MADT_TYPE_NMI_SOURCE:
305
306             InfoTable = AcpiDmTableInfoMadt3;
307             break;
308
309         case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
310
311             InfoTable = AcpiDmTableInfoMadt4;
312             break;
313
314         case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
315
316             InfoTable = AcpiDmTableInfoMadt5;
317             break;
318
319         case ACPI_MADT_TYPE_IO_SAPIC:
320
321             InfoTable = AcpiDmTableInfoMadt6;
322             break;
323
324         case ACPI_MADT_TYPE_LOCAL_SAPIC:
325
326             InfoTable = AcpiDmTableInfoMadt7;
327             break;
328
329         case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
330
331             InfoTable = AcpiDmTableInfoMadt8;
332             break;
333
334         case ACPI_MADT_TYPE_LOCAL_X2APIC:
335
336             InfoTable = AcpiDmTableInfoMadt9;
337             break;
338
339         case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
340
341             InfoTable = AcpiDmTableInfoMadt10;
342             break;
343
344         case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
345
346             InfoTable = AcpiDmTableInfoMadt11;
347             break;
348
349         case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
350
351             InfoTable = AcpiDmTableInfoMadt12;
352             break;
353
354         case ACPI_MADT_TYPE_GENERIC_MSI_FRAME:
355
356             InfoTable = AcpiDmTableInfoMadt13;
357             break;
358
359         case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR:
360
361             InfoTable = AcpiDmTableInfoMadt14;
362             break;
363
364         case ACPI_MADT_TYPE_GENERIC_TRANSLATOR:
365
366             InfoTable = AcpiDmTableInfoMadt15;
367             break;
368
369         default:
370
371             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT");
372             return (AE_ERROR);
373         }
374
375         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
376         if (ACPI_FAILURE (Status))
377         {
378             return (Status);
379         }
380
381         ParentTable = DtPeekSubtable ();
382         DtInsertSubtable (ParentTable, Subtable);
383         DtPopSubtable ();
384     }
385
386     return (AE_OK);
387 }
388
389
390 /******************************************************************************
391  *
392  * FUNCTION:    DtCompileMcfg
393  *
394  * PARAMETERS:  List                - Current field list pointer
395  *
396  * RETURN:      Status
397  *
398  * DESCRIPTION: Compile MCFG.
399  *
400  *****************************************************************************/
401
402 ACPI_STATUS
403 DtCompileMcfg (
404     void                    **List)
405 {
406     ACPI_STATUS             Status;
407
408
409     Status = DtCompileTwoSubtables (List,
410         AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0);
411     return (Status);
412 }
413
414
415 /******************************************************************************
416  *
417  * FUNCTION:    DtCompileMpst
418  *
419  * PARAMETERS:  List                - Current field list pointer
420  *
421  * RETURN:      Status
422  *
423  * DESCRIPTION: Compile MPST.
424  *
425  *****************************************************************************/
426
427 ACPI_STATUS
428 DtCompileMpst (
429     void                    **List)
430 {
431     ACPI_STATUS             Status;
432     DT_SUBTABLE             *Subtable;
433     DT_SUBTABLE             *ParentTable;
434     DT_FIELD                **PFieldList = (DT_FIELD **) List;
435     ACPI_MPST_CHANNEL       *MpstChannelInfo;
436     ACPI_MPST_POWER_NODE    *MpstPowerNode;
437     ACPI_MPST_DATA_HDR      *MpstDataHeader;
438     UINT16                  SubtableCount;
439     UINT32                  PowerStateCount;
440     UINT32                  ComponentCount;
441
442
443     /* Main table */
444
445     Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE);
446     if (ACPI_FAILURE (Status))
447     {
448         return (Status);
449     }
450
451     ParentTable = DtPeekSubtable ();
452     DtInsertSubtable (ParentTable, Subtable);
453     DtPushSubtable (Subtable);
454
455     MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer);
456     SubtableCount = MpstChannelInfo->PowerNodeCount;
457
458     while (*PFieldList && SubtableCount)
459     {
460         /* Subtable: Memory Power Node(s) */
461
462         Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0,
463             &Subtable, TRUE);
464         if (ACPI_FAILURE (Status))
465         {
466             return (Status);
467         }
468
469         ParentTable = DtPeekSubtable ();
470         DtInsertSubtable (ParentTable, Subtable);
471         DtPushSubtable (Subtable);
472
473         MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer);
474         PowerStateCount = MpstPowerNode->NumPowerStates;
475         ComponentCount = MpstPowerNode->NumPhysicalComponents;
476
477         ParentTable = DtPeekSubtable ();
478
479         /* Sub-subtables - Memory Power State Structure(s) */
480
481         while (*PFieldList && PowerStateCount)
482         {
483             Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A,
484                 &Subtable, TRUE);
485             if (ACPI_FAILURE (Status))
486             {
487                 return (Status);
488             }
489
490             DtInsertSubtable (ParentTable, Subtable);
491             PowerStateCount--;
492         }
493
494         /* Sub-subtables - Physical Component ID Structure(s) */
495
496         while (*PFieldList && ComponentCount)
497         {
498             Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B,
499                 &Subtable, TRUE);
500             if (ACPI_FAILURE (Status))
501             {
502                 return (Status);
503             }
504
505             DtInsertSubtable (ParentTable, Subtable);
506             ComponentCount--;
507         }
508
509         SubtableCount--;
510         DtPopSubtable ();
511     }
512
513     /* Subtable: Count of Memory Power State Characteristic structures */
514
515     DtPopSubtable ();
516
517     Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE);
518     if (ACPI_FAILURE (Status))
519     {
520         return (Status);
521     }
522
523     ParentTable = DtPeekSubtable ();
524     DtInsertSubtable (ParentTable, Subtable);
525     DtPushSubtable (Subtable);
526
527     MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer);
528     SubtableCount = MpstDataHeader->CharacteristicsCount;
529
530     ParentTable = DtPeekSubtable ();
531
532     /* Subtable: Memory Power State Characteristics structure(s) */
533
534     while (*PFieldList && SubtableCount)
535     {
536         Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2,
537             &Subtable, TRUE);
538         if (ACPI_FAILURE (Status))
539         {
540             return (Status);
541         }
542
543         DtInsertSubtable (ParentTable, Subtable);
544         SubtableCount--;
545     }
546
547     DtPopSubtable ();
548     return (AE_OK);
549 }
550
551
552 /******************************************************************************
553  *
554  * FUNCTION:    DtCompileMsct
555  *
556  * PARAMETERS:  List                - Current field list pointer
557  *
558  * RETURN:      Status
559  *
560  * DESCRIPTION: Compile MSCT.
561  *
562  *****************************************************************************/
563
564 ACPI_STATUS
565 DtCompileMsct (
566     void                    **List)
567 {
568     ACPI_STATUS             Status;
569
570
571     Status = DtCompileTwoSubtables (List,
572         AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0);
573     return (Status);
574 }
575
576
577 /******************************************************************************
578  *
579  * FUNCTION:    DtCompileMtmr
580  *
581  * PARAMETERS:  List                - Current field list pointer
582  *
583  * RETURN:      Status
584  *
585  * DESCRIPTION: Compile MTMR.
586  *
587  *****************************************************************************/
588
589 ACPI_STATUS
590 DtCompileMtmr (
591     void                    **List)
592 {
593     ACPI_STATUS             Status;
594
595
596     Status = DtCompileTwoSubtables (List,
597         AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0);
598     return (Status);
599 }
600
601
602 /******************************************************************************
603  *
604  * FUNCTION:    DtCompileNfit
605  *
606  * PARAMETERS:  List                - Current field list pointer
607  *
608  * RETURN:      Status
609  *
610  * DESCRIPTION: Compile NFIT.
611  *
612  *****************************************************************************/
613
614 ACPI_STATUS
615 DtCompileNfit (
616     void                    **List)
617 {
618     ACPI_STATUS             Status;
619     DT_SUBTABLE             *Subtable;
620     DT_SUBTABLE             *ParentTable;
621     DT_FIELD                **PFieldList = (DT_FIELD **) List;
622     DT_FIELD                *SubtableStart;
623     ACPI_NFIT_HEADER        *NfitHeader;
624     ACPI_DMTABLE_INFO       *InfoTable;
625     UINT32                  Count;
626     ACPI_NFIT_INTERLEAVE    *Interleave = NULL;
627     ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
628
629
630     /* Main table */
631
632     Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit,
633         &Subtable, TRUE);
634     if (ACPI_FAILURE (Status))
635     {
636         return (Status);
637     }
638
639     ParentTable = DtPeekSubtable ();
640     DtInsertSubtable (ParentTable, Subtable);
641     DtPushSubtable (Subtable);
642
643     /* Subtables */
644
645     while (*PFieldList)
646     {
647         SubtableStart = *PFieldList;
648         Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr,
649             &Subtable, TRUE);
650         if (ACPI_FAILURE (Status))
651         {
652             return (Status);
653         }
654
655         ParentTable = DtPeekSubtable ();
656         DtInsertSubtable (ParentTable, Subtable);
657         DtPushSubtable (Subtable);
658
659         NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
660
661         switch (NfitHeader->Type)
662         {
663         case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
664
665             InfoTable = AcpiDmTableInfoNfit0;
666             break;
667
668         case ACPI_NFIT_TYPE_MEMORY_MAP:
669
670             InfoTable = AcpiDmTableInfoNfit1;
671             break;
672
673         case ACPI_NFIT_TYPE_INTERLEAVE:
674
675             Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer);
676             InfoTable = AcpiDmTableInfoNfit2;
677             break;
678
679         case ACPI_NFIT_TYPE_SMBIOS:
680
681             InfoTable = AcpiDmTableInfoNfit3;
682             break;
683
684         case ACPI_NFIT_TYPE_CONTROL_REGION:
685
686             InfoTable = AcpiDmTableInfoNfit4;
687             break;
688
689         case ACPI_NFIT_TYPE_DATA_REGION:
690
691             InfoTable = AcpiDmTableInfoNfit5;
692             break;
693
694         case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
695
696             Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer);
697             InfoTable = AcpiDmTableInfoNfit6;
698             break;
699
700         default:
701
702             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT");
703             return (AE_ERROR);
704         }
705
706         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
707         if (ACPI_FAILURE (Status))
708         {
709             return (Status);
710         }
711
712         ParentTable = DtPeekSubtable ();
713         DtInsertSubtable (ParentTable, Subtable);
714         DtPopSubtable ();
715
716         switch (NfitHeader->Type)
717         {
718         case ACPI_NFIT_TYPE_INTERLEAVE:
719
720             Count = 0;
721             DtPushSubtable (Subtable);
722             while (*PFieldList)
723             {
724                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a,
725                     &Subtable, FALSE);
726                 if (ACPI_FAILURE (Status))
727                 {
728                     return (Status);
729                 }
730
731                 if (!Subtable)
732                 {
733                     DtPopSubtable ();
734                     break;
735                 }
736
737                 ParentTable = DtPeekSubtable ();
738                 DtInsertSubtable (ParentTable, Subtable);
739                 Count++;
740             }
741
742             Interleave->LineCount = Count;
743             DtPopSubtable ();
744             break;
745
746         case ACPI_NFIT_TYPE_SMBIOS:
747
748             if (*PFieldList)
749             {
750                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a,
751                     &Subtable, TRUE);
752                 if (ACPI_FAILURE (Status))
753                 {
754                     return (Status);
755                 }
756
757                 if (Subtable)
758                 {
759                     DtInsertSubtable (ParentTable, Subtable);
760                 }
761             }
762             break;
763
764         case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
765
766             Count = 0;
767             DtPushSubtable (Subtable);
768             while (*PFieldList)
769             {
770                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a,
771                     &Subtable, FALSE);
772                 if (ACPI_FAILURE (Status))
773                 {
774                     return (Status);
775                 }
776
777                 if (!Subtable)
778                 {
779                     DtPopSubtable ();
780                     break;
781                 }
782
783                 ParentTable = DtPeekSubtable ();
784                 DtInsertSubtable (ParentTable, Subtable);
785                 Count++;
786             }
787
788             Hint->HintCount = (UINT16) Count;
789             DtPopSubtable ();
790             break;
791
792         default:
793             break;
794         }
795     }
796
797     return (AE_OK);
798 }
799
800
801 /******************************************************************************
802  *
803  * FUNCTION:    DtCompilePcct
804  *
805  * PARAMETERS:  List                - Current field list pointer
806  *
807  * RETURN:      Status
808  *
809  * DESCRIPTION: Compile PCCT.
810  *
811  *****************************************************************************/
812
813 ACPI_STATUS
814 DtCompilePcct (
815     void                    **List)
816 {
817     ACPI_STATUS             Status;
818     DT_SUBTABLE             *Subtable;
819     DT_SUBTABLE             *ParentTable;
820     DT_FIELD                **PFieldList = (DT_FIELD **) List;
821     DT_FIELD                *SubtableStart;
822     ACPI_SUBTABLE_HEADER    *PcctHeader;
823     ACPI_DMTABLE_INFO       *InfoTable;
824
825
826     /* Main table */
827
828     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct,
829         &Subtable, TRUE);
830     if (ACPI_FAILURE (Status))
831     {
832         return (Status);
833     }
834
835     ParentTable = DtPeekSubtable ();
836     DtInsertSubtable (ParentTable, Subtable);
837
838     /* Subtables */
839
840     while (*PFieldList)
841     {
842         SubtableStart = *PFieldList;
843         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr,
844             &Subtable, TRUE);
845         if (ACPI_FAILURE (Status))
846         {
847             return (Status);
848         }
849
850         ParentTable = DtPeekSubtable ();
851         DtInsertSubtable (ParentTable, Subtable);
852         DtPushSubtable (Subtable);
853
854         PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
855
856         switch (PcctHeader->Type)
857         {
858         case ACPI_PCCT_TYPE_GENERIC_SUBSPACE:
859
860             InfoTable = AcpiDmTableInfoPcct0;
861             break;
862
863         case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE:
864
865             InfoTable = AcpiDmTableInfoPcct1;
866             break;
867
868         case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2:
869
870             InfoTable = AcpiDmTableInfoPcct2;
871             break;
872
873         case ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE:
874
875             InfoTable = AcpiDmTableInfoPcct3;
876             break;
877
878         case ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE:
879
880             InfoTable = AcpiDmTableInfoPcct4;
881             break;
882
883         default:
884
885             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT");
886             return (AE_ERROR);
887         }
888
889         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
890         if (ACPI_FAILURE (Status))
891         {
892             return (Status);
893         }
894
895         ParentTable = DtPeekSubtable ();
896         DtInsertSubtable (ParentTable, Subtable);
897         DtPopSubtable ();
898     }
899
900     return (AE_OK);
901 }
902
903
904 /******************************************************************************
905  *
906  * FUNCTION:    DtCompilePdtt
907  *
908  * PARAMETERS:  List                - Current field list pointer
909  *
910  * RETURN:      Status
911  *
912  * DESCRIPTION: Compile PDTT.
913  *
914  *****************************************************************************/
915
916 ACPI_STATUS
917 DtCompilePdtt (
918     void                    **List)
919 {
920     ACPI_STATUS             Status;
921     DT_SUBTABLE             *Subtable;
922     DT_SUBTABLE             *ParentTable;
923     DT_FIELD                **PFieldList = (DT_FIELD **) List;
924     ACPI_TABLE_PDTT         *PdttHeader;
925     UINT32                  Count = 0;
926
927
928     /* Main table */
929
930     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt, &Subtable, TRUE);
931     if (ACPI_FAILURE (Status))
932     {
933         return (Status);
934     }
935
936     ParentTable = DtPeekSubtable ();
937     DtInsertSubtable (ParentTable, Subtable);
938
939     PdttHeader = ACPI_CAST_PTR (ACPI_TABLE_PDTT, ParentTable->Buffer);
940     PdttHeader->ArrayOffset = sizeof (ACPI_TABLE_PDTT);
941
942     /* There is only one type of subtable at this time, no need to decode */
943
944     while (*PFieldList)
945     {
946         /* List of subchannel IDs, each 2 bytes */
947
948         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt0,
949             &Subtable, TRUE);
950         if (ACPI_FAILURE (Status))
951         {
952             return (Status);
953         }
954
955         DtInsertSubtable (ParentTable, Subtable);
956         Count++;
957     }
958
959     PdttHeader->TriggerCount = (UINT8) Count;
960     return (AE_OK);
961 }
962
963
964 /******************************************************************************
965  *
966  * FUNCTION:    DtCompilePmtt
967  *
968  * PARAMETERS:  List                - Current field list pointer
969  *
970  * RETURN:      Status
971  *
972  * DESCRIPTION: Compile PMTT.
973  *
974  *****************************************************************************/
975
976 ACPI_STATUS
977 DtCompilePmtt (
978     void                    **List)
979 {
980     ACPI_STATUS             Status;
981     DT_SUBTABLE             *Subtable;
982     DT_SUBTABLE             *ParentTable;
983     DT_FIELD                **PFieldList = (DT_FIELD **) List;
984     DT_FIELD                *SubtableStart;
985     ACPI_PMTT_HEADER        *PmttHeader;
986     ACPI_PMTT_CONTROLLER    *PmttController;
987     UINT16                  DomainCount;
988     UINT8                   PrevType = ACPI_PMTT_TYPE_SOCKET;
989
990
991     /* Main table */
992
993     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE);
994     if (ACPI_FAILURE (Status))
995     {
996         return (Status);
997     }
998
999     ParentTable = DtPeekSubtable ();
1000     DtInsertSubtable (ParentTable, Subtable);
1001     DtPushSubtable (Subtable);
1002
1003     while (*PFieldList)
1004     {
1005         SubtableStart = *PFieldList;
1006         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr,
1007             &Subtable, TRUE);
1008         if (ACPI_FAILURE (Status))
1009         {
1010             return (Status);
1011         }
1012
1013         PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer);
1014         while (PrevType >= PmttHeader->Type)
1015         {
1016             DtPopSubtable ();
1017
1018             if (PrevType == ACPI_PMTT_TYPE_SOCKET)
1019             {
1020                 break;
1021             }
1022
1023             PrevType--;
1024         }
1025
1026         PrevType = PmttHeader->Type;
1027
1028         ParentTable = DtPeekSubtable ();
1029         DtInsertSubtable (ParentTable, Subtable);
1030         DtPushSubtable (Subtable);
1031
1032         switch (PmttHeader->Type)
1033         {
1034         case ACPI_PMTT_TYPE_SOCKET:
1035
1036             /* Subtable: Socket Structure */
1037
1038             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0,
1039                 &Subtable, TRUE);
1040             if (ACPI_FAILURE (Status))
1041             {
1042                 return (Status);
1043             }
1044
1045             ParentTable = DtPeekSubtable ();
1046             DtInsertSubtable (ParentTable, Subtable);
1047             break;
1048
1049         case ACPI_PMTT_TYPE_CONTROLLER:
1050
1051             /* Subtable: Memory Controller Structure */
1052
1053             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1,
1054                 &Subtable, TRUE);
1055             if (ACPI_FAILURE (Status))
1056             {
1057                 return (Status);
1058             }
1059
1060             ParentTable = DtPeekSubtable ();
1061             DtInsertSubtable (ParentTable, Subtable);
1062
1063             PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER,
1064                 (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER)));
1065             DomainCount = PmttController->DomainCount;
1066
1067             while (DomainCount)
1068             {
1069                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a,
1070                     &Subtable, TRUE);
1071                 if (ACPI_FAILURE (Status))
1072                 {
1073                     return (Status);
1074                 }
1075
1076                 DtInsertSubtable (ParentTable, Subtable);
1077                 DomainCount--;
1078             }
1079             break;
1080
1081         case ACPI_PMTT_TYPE_DIMM:
1082
1083             /* Subtable: Physical Component Structure */
1084
1085             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2,
1086                 &Subtable, TRUE);
1087             if (ACPI_FAILURE (Status))
1088             {
1089                 return (Status);
1090             }
1091
1092             ParentTable = DtPeekSubtable ();
1093             DtInsertSubtable (ParentTable, Subtable);
1094             break;
1095
1096         default:
1097
1098             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT");
1099             return (AE_ERROR);
1100         }
1101     }
1102
1103     return (Status);
1104 }
1105
1106
1107 /******************************************************************************
1108  *
1109  * FUNCTION:    DtCompilePptt
1110  *
1111  * PARAMETERS:  List                - Current field list pointer
1112  *
1113  * RETURN:      Status
1114  *
1115  * DESCRIPTION: Compile PPTT.
1116  *
1117  *****************************************************************************/
1118
1119 ACPI_STATUS
1120 DtCompilePptt (
1121     void                    **List)
1122 {
1123     ACPI_STATUS             Status;
1124     ACPI_SUBTABLE_HEADER    *PpttHeader;
1125     ACPI_PPTT_PROCESSOR     *PpttProcessor = NULL;
1126     DT_SUBTABLE             *Subtable;
1127     DT_SUBTABLE             *ParentTable;
1128     ACPI_DMTABLE_INFO       *InfoTable;
1129     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1130     DT_FIELD                *SubtableStart;
1131
1132
1133     ParentTable = DtPeekSubtable ();
1134     while (*PFieldList)
1135     {
1136         SubtableStart = *PFieldList;
1137
1138         /* Compile PPTT subtable header */
1139
1140         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPpttHdr,
1141             &Subtable, TRUE);
1142         if (ACPI_FAILURE (Status))
1143         {
1144             return (Status);
1145         }
1146         DtInsertSubtable (ParentTable, Subtable);
1147         PpttHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1148         PpttHeader->Length = (UINT8)(Subtable->Length);
1149
1150         switch (PpttHeader->Type)
1151         {
1152         case ACPI_PPTT_TYPE_PROCESSOR:
1153
1154             InfoTable = AcpiDmTableInfoPptt0;
1155             break;
1156
1157         case ACPI_PPTT_TYPE_CACHE:
1158
1159             InfoTable = AcpiDmTableInfoPptt1;
1160             break;
1161
1162         case ACPI_PPTT_TYPE_ID:
1163
1164             InfoTable = AcpiDmTableInfoPptt2;
1165             break;
1166
1167         default:
1168
1169             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PPTT");
1170             return (AE_ERROR);
1171         }
1172
1173         /* Compile PPTT subtable body */
1174
1175         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1176         if (ACPI_FAILURE (Status))
1177         {
1178             return (Status);
1179         }
1180         DtInsertSubtable (ParentTable, Subtable);
1181         PpttHeader->Length += (UINT8)(Subtable->Length);
1182
1183         /* Compile PPTT subtable additionals */
1184
1185         switch (PpttHeader->Type)
1186         {
1187         case ACPI_PPTT_TYPE_PROCESSOR:
1188
1189             PpttProcessor = ACPI_SUB_PTR (ACPI_PPTT_PROCESSOR,
1190                 Subtable->Buffer, sizeof (ACPI_SUBTABLE_HEADER));
1191             if (PpttProcessor)
1192             {
1193                 /* Compile initiator proximity domain list */
1194
1195                 PpttProcessor->NumberOfPrivResources = 0;
1196                 while (*PFieldList)
1197                 {
1198                     Status = DtCompileTable (PFieldList,
1199                         AcpiDmTableInfoPptt0a, &Subtable, TRUE);
1200                     if (ACPI_FAILURE (Status))
1201                     {
1202                         return (Status);
1203                     }
1204                     if (!Subtable)
1205                     {
1206                         break;
1207                     }
1208
1209                     DtInsertSubtable (ParentTable, Subtable);
1210                     PpttHeader->Length += (UINT8)(Subtable->Length);
1211                     PpttProcessor->NumberOfPrivResources++;
1212                 }
1213             }
1214             break;
1215
1216         default:
1217
1218             break;
1219         }
1220     }
1221
1222     return (AE_OK);
1223 }
1224
1225
1226 /******************************************************************************
1227  *
1228  * FUNCTION:    DtCompileRsdt
1229  *
1230  * PARAMETERS:  List                - Current field list pointer
1231  *
1232  * RETURN:      Status
1233  *
1234  * DESCRIPTION: Compile RSDT.
1235  *
1236  *****************************************************************************/
1237
1238 ACPI_STATUS
1239 DtCompileRsdt (
1240     void                    **List)
1241 {
1242     DT_SUBTABLE             *Subtable;
1243     DT_SUBTABLE             *ParentTable;
1244     DT_FIELD                *FieldList = *(DT_FIELD **) List;
1245     UINT32                  Address;
1246
1247
1248     ParentTable = DtPeekSubtable ();
1249
1250     while (FieldList)
1251     {
1252         DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO);
1253
1254         DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable);
1255         DtInsertSubtable (ParentTable, Subtable);
1256         FieldList = FieldList->Next;
1257     }
1258
1259     return (AE_OK);
1260 }
1261
1262
1263 /******************************************************************************
1264  *
1265  * FUNCTION:    DtCompileS3pt
1266  *
1267  * PARAMETERS:  PFieldList          - Current field list pointer
1268  *
1269  * RETURN:      Status
1270  *
1271  * DESCRIPTION: Compile S3PT (Pointed to by FPDT)
1272  *
1273  *****************************************************************************/
1274
1275 ACPI_STATUS
1276 DtCompileS3pt (
1277     DT_FIELD                **PFieldList)
1278 {
1279     ACPI_STATUS             Status;
1280     ACPI_FPDT_HEADER        *S3ptHeader;
1281     DT_SUBTABLE             *Subtable;
1282     DT_SUBTABLE             *ParentTable;
1283     ACPI_DMTABLE_INFO       *InfoTable;
1284     DT_FIELD                *SubtableStart;
1285
1286
1287     Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt,
1288         &Gbl_RootTable, TRUE);
1289     if (ACPI_FAILURE (Status))
1290     {
1291         return (Status);
1292     }
1293
1294     DtPushSubtable (Gbl_RootTable);
1295
1296     while (*PFieldList)
1297     {
1298         SubtableStart = *PFieldList;
1299         Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr,
1300             &Subtable, TRUE);
1301         if (ACPI_FAILURE (Status))
1302         {
1303             return (Status);
1304         }
1305
1306         ParentTable = DtPeekSubtable ();
1307         DtInsertSubtable (ParentTable, Subtable);
1308         DtPushSubtable (Subtable);
1309
1310         S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
1311
1312         switch (S3ptHeader->Type)
1313         {
1314         case ACPI_S3PT_TYPE_RESUME:
1315
1316             InfoTable = AcpiDmTableInfoS3pt0;
1317             break;
1318
1319         case ACPI_S3PT_TYPE_SUSPEND:
1320
1321             InfoTable = AcpiDmTableInfoS3pt1;
1322             break;
1323
1324         default:
1325
1326             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT");
1327             return (AE_ERROR);
1328         }
1329
1330         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1331         if (ACPI_FAILURE (Status))
1332         {
1333             return (Status);
1334         }
1335
1336         ParentTable = DtPeekSubtable ();
1337         DtInsertSubtable (ParentTable, Subtable);
1338         DtPopSubtable ();
1339     }
1340
1341     return (AE_OK);
1342 }
1343
1344
1345 /******************************************************************************
1346  *
1347  * FUNCTION:    DtCompileSdev
1348  *
1349  * PARAMETERS:  List                - Current field list pointer
1350  *
1351  * RETURN:      Status
1352  *
1353  * DESCRIPTION: Compile SDEV.
1354  *
1355  *****************************************************************************/
1356
1357 ACPI_STATUS
1358 DtCompileSdev (
1359     void                    **List)
1360 {
1361     ACPI_STATUS             Status;
1362     ACPI_SDEV_HEADER        *SdevHeader;
1363     DT_SUBTABLE             *Subtable;
1364     DT_SUBTABLE             *ParentTable;
1365     ACPI_DMTABLE_INFO       *InfoTable;
1366     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1367     DT_FIELD                *SubtableStart;
1368     ACPI_SDEV_PCIE          *Pcie = NULL;
1369     ACPI_SDEV_NAMESPACE     *Namesp = NULL;
1370     UINT32                  EntryCount;
1371
1372
1373     /* Subtables */
1374
1375     while (*PFieldList)
1376     {
1377         /* Compile common SDEV subtable header */
1378
1379         SubtableStart = *PFieldList;
1380         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevHdr,
1381             &Subtable, TRUE);
1382         if (ACPI_FAILURE (Status))
1383         {
1384             return (Status);
1385         }
1386
1387         ParentTable = DtPeekSubtable ();
1388         DtInsertSubtable (ParentTable, Subtable);
1389         DtPushSubtable (Subtable);
1390
1391         SdevHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer);
1392         SdevHeader->Length = (UINT8)(sizeof (ACPI_SDEV_HEADER));
1393
1394         switch (SdevHeader->Type)
1395         {
1396         case ACPI_SDEV_TYPE_NAMESPACE_DEVICE:
1397
1398             InfoTable = AcpiDmTableInfoSdev0;
1399             Namesp = ACPI_CAST_PTR (ACPI_SDEV_NAMESPACE, Subtable->Buffer);
1400             break;
1401
1402         case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
1403
1404             InfoTable = AcpiDmTableInfoSdev1;
1405             Pcie = ACPI_CAST_PTR (ACPI_SDEV_PCIE, Subtable->Buffer);
1406             break;
1407
1408         default:
1409
1410             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV");
1411             return (AE_ERROR);
1412         }
1413
1414         /* Compile SDEV subtable body */
1415
1416         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1417         if (ACPI_FAILURE (Status))
1418         {
1419             return (Status);
1420         }
1421
1422         ParentTable = DtPeekSubtable ();
1423         DtInsertSubtable (ParentTable, Subtable);
1424
1425         /* Optional data fields are appended to the main subtable body */
1426
1427         switch (SdevHeader->Type)
1428         {
1429         case ACPI_SDEV_TYPE_NAMESPACE_DEVICE:
1430
1431             /* Append DeviceId namespace string */
1432
1433             Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0a,
1434                 &Subtable, TRUE);
1435             if (ACPI_FAILURE (Status))
1436             {
1437                 return (Status);
1438             }
1439
1440             if (!Subtable)
1441             {
1442                 break;
1443             }
1444
1445             ParentTable = DtPeekSubtable ();
1446             DtInsertSubtable (ParentTable, Subtable);
1447
1448             Namesp->DeviceIdOffset = sizeof (ACPI_SDEV_NAMESPACE);
1449             Namesp->DeviceIdLength = (UINT16) Subtable->Length;
1450
1451             /* Append Vendor data */
1452
1453             Namesp->VendorDataLength = 0;
1454             Namesp->VendorDataOffset = 0;
1455
1456             if (*PFieldList)
1457             {
1458                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b,
1459                     &Subtable, TRUE);
1460                 if (ACPI_FAILURE (Status))
1461                 {
1462                     return (Status);
1463                 }
1464
1465                 if (Subtable)
1466                 {
1467                     ParentTable = DtPeekSubtable ();
1468                     DtInsertSubtable (ParentTable, Subtable);
1469
1470                     Namesp->VendorDataOffset =
1471                         Namesp->DeviceIdOffset + Namesp->DeviceIdLength;
1472                     Namesp->VendorDataLength =
1473                         (UINT16) Subtable->Length;
1474                 }
1475             }
1476
1477             /* Final size of entire namespace structure */
1478
1479             SdevHeader->Length = (UINT16) (sizeof (ACPI_SDEV_NAMESPACE) +
1480                 Subtable->Length + Namesp->DeviceIdLength);
1481             break;
1482
1483         case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
1484
1485             /* Append the PCIe path info first */
1486
1487             EntryCount = 0;
1488             while (*PFieldList && !strcmp ((*PFieldList)->Name, "Device"))
1489             {
1490                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1a,
1491                     &Subtable, FALSE);
1492                 if (ACPI_FAILURE (Status))
1493                 {
1494                     return (Status);
1495                 }
1496
1497                 if (!Subtable)
1498                 {
1499                     DtPopSubtable ();
1500                     break;
1501                 }
1502
1503                 ParentTable = DtPeekSubtable ();
1504                 DtInsertSubtable (ParentTable, Subtable);
1505                 EntryCount++;
1506             }
1507
1508             /* Path offset will point immediately after the main subtable */
1509
1510             Pcie->PathOffset = sizeof (ACPI_SDEV_PCIE);
1511             Pcie->PathLength = (UINT16)
1512                 (EntryCount * sizeof (ACPI_SDEV_PCIE_PATH));
1513
1514             /* Append the Vendor Data last */
1515
1516             Pcie->VendorDataLength = 0;
1517             Pcie->VendorDataOffset = 0;
1518
1519             if (*PFieldList)
1520             {
1521                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b,
1522                     &Subtable, TRUE);
1523                 if (ACPI_FAILURE (Status))
1524                 {
1525                     return (Status);
1526                 }
1527
1528                 if (Subtable)
1529                 {
1530                     ParentTable = DtPeekSubtable ();
1531                     DtInsertSubtable (ParentTable, Subtable);
1532
1533                     Pcie->VendorDataOffset =
1534                         Pcie->PathOffset + Pcie->PathLength;
1535                     Pcie->VendorDataLength = (UINT16)
1536                         Subtable->Length;
1537                 }
1538             }
1539
1540             SdevHeader->Length =
1541                 sizeof (ACPI_SDEV_PCIE) +
1542                 Pcie->PathLength + Pcie->VendorDataLength;
1543             break;
1544
1545         default:
1546
1547             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV");
1548             return (AE_ERROR);
1549         }
1550
1551         DtPopSubtable ();
1552     }
1553
1554     return (AE_OK);
1555 }
1556
1557
1558 /******************************************************************************
1559  *
1560  * FUNCTION:    DtCompileSlic
1561  *
1562  * PARAMETERS:  List                - Current field list pointer
1563  *
1564  * RETURN:      Status
1565  *
1566  * DESCRIPTION: Compile SLIC.
1567  *
1568  *****************************************************************************/
1569
1570 ACPI_STATUS
1571 DtCompileSlic (
1572     void                    **List)
1573 {
1574     ACPI_STATUS             Status;
1575     DT_SUBTABLE             *Subtable;
1576     DT_SUBTABLE             *ParentTable;
1577     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1578
1579
1580     while (*PFieldList)
1581     {
1582         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic,
1583             &Subtable, TRUE);
1584         if (ACPI_FAILURE (Status))
1585         {
1586             return (Status);
1587         }
1588
1589         ParentTable = DtPeekSubtable ();
1590         DtInsertSubtable (ParentTable, Subtable);
1591         DtPushSubtable (Subtable);
1592         DtPopSubtable ();
1593     }
1594
1595     return (AE_OK);
1596 }
1597
1598
1599 /******************************************************************************
1600  *
1601  * FUNCTION:    DtCompileSlit
1602  *
1603  * PARAMETERS:  List                - Current field list pointer
1604  *
1605  * RETURN:      Status
1606  *
1607  * DESCRIPTION: Compile SLIT.
1608  *
1609  *****************************************************************************/
1610
1611 ACPI_STATUS
1612 DtCompileSlit (
1613     void                    **List)
1614 {
1615     ACPI_STATUS             Status;
1616     DT_SUBTABLE             *Subtable;
1617     DT_SUBTABLE             *ParentTable;
1618     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1619     DT_FIELD                *FieldList;
1620     UINT32                  Localities;
1621     UINT8                   *LocalityBuffer;
1622
1623
1624     Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
1625         &Subtable, TRUE);
1626     if (ACPI_FAILURE (Status))
1627     {
1628         return (Status);
1629     }
1630
1631     ParentTable = DtPeekSubtable ();
1632     DtInsertSubtable (ParentTable, Subtable);
1633
1634     Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
1635     LocalityBuffer = UtLocalCalloc (Localities);
1636
1637     /* Compile each locality buffer */
1638
1639     FieldList = *PFieldList;
1640     while (FieldList)
1641     {
1642         DtCompileBuffer (LocalityBuffer,
1643             FieldList->Value, FieldList, Localities);
1644
1645         DtCreateSubtable (LocalityBuffer, Localities, &Subtable);
1646         DtInsertSubtable (ParentTable, Subtable);
1647         FieldList = FieldList->Next;
1648     }
1649
1650     ACPI_FREE (LocalityBuffer);
1651     return (AE_OK);
1652 }
1653
1654
1655 /******************************************************************************
1656  *
1657  * FUNCTION:    DtCompileSrat
1658  *
1659  * PARAMETERS:  List                - Current field list pointer
1660  *
1661  * RETURN:      Status
1662  *
1663  * DESCRIPTION: Compile SRAT.
1664  *
1665  *****************************************************************************/
1666
1667 ACPI_STATUS
1668 DtCompileSrat (
1669     void                    **List)
1670 {
1671     ACPI_STATUS             Status;
1672     DT_SUBTABLE             *Subtable;
1673     DT_SUBTABLE             *ParentTable;
1674     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1675     DT_FIELD                *SubtableStart;
1676     ACPI_SUBTABLE_HEADER    *SratHeader;
1677     ACPI_DMTABLE_INFO       *InfoTable;
1678
1679
1680     Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat,
1681         &Subtable, TRUE);
1682     if (ACPI_FAILURE (Status))
1683     {
1684         return (Status);
1685     }
1686
1687     ParentTable = DtPeekSubtable ();
1688     DtInsertSubtable (ParentTable, Subtable);
1689
1690     while (*PFieldList)
1691     {
1692         SubtableStart = *PFieldList;
1693         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr,
1694             &Subtable, TRUE);
1695         if (ACPI_FAILURE (Status))
1696         {
1697             return (Status);
1698         }
1699
1700         ParentTable = DtPeekSubtable ();
1701         DtInsertSubtable (ParentTable, Subtable);
1702         DtPushSubtable (Subtable);
1703
1704         SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1705
1706         switch (SratHeader->Type)
1707         {
1708         case ACPI_SRAT_TYPE_CPU_AFFINITY:
1709
1710             InfoTable = AcpiDmTableInfoSrat0;
1711             break;
1712
1713         case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
1714
1715             InfoTable = AcpiDmTableInfoSrat1;
1716             break;
1717
1718         case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
1719
1720             InfoTable = AcpiDmTableInfoSrat2;
1721             break;
1722
1723         case ACPI_SRAT_TYPE_GICC_AFFINITY:
1724
1725             InfoTable = AcpiDmTableInfoSrat3;
1726             break;
1727
1728         case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
1729
1730             InfoTable = AcpiDmTableInfoSrat4;
1731             break;
1732
1733         default:
1734
1735             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT");
1736             return (AE_ERROR);
1737         }
1738
1739         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1740         if (ACPI_FAILURE (Status))
1741         {
1742             return (Status);
1743         }
1744
1745         ParentTable = DtPeekSubtable ();
1746         DtInsertSubtable (ParentTable, Subtable);
1747         DtPopSubtable ();
1748     }
1749
1750     return (AE_OK);
1751 }
1752
1753
1754 /******************************************************************************
1755  *
1756  * FUNCTION:    DtCompileStao
1757  *
1758  * PARAMETERS:  PFieldList          - Current field list pointer
1759  *
1760  * RETURN:      Status
1761  *
1762  * DESCRIPTION: Compile STAO.
1763  *
1764  *****************************************************************************/
1765
1766 ACPI_STATUS
1767 DtCompileStao (
1768     void                    **List)
1769 {
1770     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1771     DT_SUBTABLE             *Subtable;
1772     DT_SUBTABLE             *ParentTable;
1773     ACPI_STATUS             Status;
1774
1775
1776     /* Compile the main table */
1777
1778     Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao,
1779         &Subtable, TRUE);
1780     if (ACPI_FAILURE (Status))
1781     {
1782         return (Status);
1783     }
1784
1785     ParentTable = DtPeekSubtable ();
1786     DtInsertSubtable (ParentTable, Subtable);
1787
1788     /* Compile each ASCII namestring as a subtable */
1789
1790     while (*PFieldList)
1791     {
1792         Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr,
1793             &Subtable, TRUE);
1794         if (ACPI_FAILURE (Status))
1795         {
1796             return (Status);
1797         }
1798
1799         ParentTable = DtPeekSubtable ();
1800         DtInsertSubtable (ParentTable, Subtable);
1801     }
1802
1803     return (AE_OK);
1804 }
1805
1806
1807 /******************************************************************************
1808  *
1809  * FUNCTION:    DtCompileTcpa
1810  *
1811  * PARAMETERS:  PFieldList          - Current field list pointer
1812  *
1813  * RETURN:      Status
1814  *
1815  * DESCRIPTION: Compile TCPA.
1816  *
1817  *****************************************************************************/
1818
1819 ACPI_STATUS
1820 DtCompileTcpa (
1821     void                    **List)
1822 {
1823     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1824     DT_SUBTABLE             *Subtable;
1825     ACPI_TABLE_TCPA_HDR     *TcpaHeader;
1826     DT_SUBTABLE             *ParentTable;
1827     ACPI_STATUS             Status;
1828
1829
1830     /* Compile the main table */
1831
1832     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr,
1833         &Subtable, TRUE);
1834     if (ACPI_FAILURE (Status))
1835     {
1836         return (Status);
1837     }
1838
1839     ParentTable = DtPeekSubtable ();
1840     DtInsertSubtable (ParentTable, Subtable);
1841
1842     /*
1843      * Examine the PlatformClass field to determine the table type.
1844      * Either a client or server table. Only one.
1845      */
1846     TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer);
1847
1848     switch (TcpaHeader->PlatformClass)
1849     {
1850     case ACPI_TCPA_CLIENT_TABLE:
1851
1852         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient,
1853             &Subtable, TRUE);
1854         break;
1855
1856     case ACPI_TCPA_SERVER_TABLE:
1857
1858         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer,
1859             &Subtable, TRUE);
1860         break;
1861
1862     default:
1863
1864         AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
1865             TcpaHeader->PlatformClass);
1866         Status = AE_ERROR;
1867         break;
1868     }
1869
1870     ParentTable = DtPeekSubtable ();
1871     DtInsertSubtable (ParentTable, Subtable);
1872     return (Status);
1873 }
1874
1875
1876 /******************************************************************************
1877  *
1878  * FUNCTION:    DtCompileTpm2
1879  *
1880  * PARAMETERS:  PFieldList          - Current field list pointer
1881  *
1882  * RETURN:      Status
1883  *
1884  * DESCRIPTION: Compile TPM2.
1885  *
1886  *****************************************************************************/
1887
1888 ACPI_STATUS
1889 DtCompileTpm2 (
1890     void                    **List)
1891 {
1892     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1893     DT_SUBTABLE             *Subtable;
1894     ACPI_TABLE_TPM2         *Tpm2Header;
1895     DT_SUBTABLE             *ParentTable;
1896     ACPI_STATUS             Status = AE_OK;
1897
1898
1899     /* Compile the main table */
1900
1901     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2,
1902         &Subtable, TRUE);
1903     if (ACPI_FAILURE (Status))
1904     {
1905         return (Status);
1906     }
1907
1908     ParentTable = DtPeekSubtable ();
1909     DtInsertSubtable (ParentTable, Subtable);
1910
1911     Tpm2Header = ACPI_CAST_PTR (ACPI_TABLE_TPM2, ParentTable->Buffer);
1912
1913     /* Method parameters */
1914     /* Optional: Log area minimum length */
1915     /* Optional: Log area start address */
1916     /* TBD: Optional fields above not fully implemented (not optional at this time) */
1917
1918     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2a,
1919         &Subtable, TRUE);
1920     if (ACPI_FAILURE (Status))
1921     {
1922         return (Status);
1923     }
1924
1925     ParentTable = DtPeekSubtable ();
1926     DtInsertSubtable (ParentTable, Subtable);
1927
1928
1929     /* Subtable type depends on the StartMethod */
1930
1931     switch (Tpm2Header->StartMethod)
1932     {
1933     case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
1934
1935         /* Subtable specific to to ARM_SMC */
1936
1937         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm211,
1938             &Subtable, TRUE);
1939         if (ACPI_FAILURE (Status))
1940         {
1941             return (Status);
1942         }
1943
1944         ParentTable = DtPeekSubtable ();
1945         DtInsertSubtable (ParentTable, Subtable);
1946         break;
1947
1948     case ACPI_TPM2_START_METHOD:
1949     case ACPI_TPM2_MEMORY_MAPPED:
1950     case ACPI_TPM2_COMMAND_BUFFER:
1951     case ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD:
1952         break;
1953
1954     case ACPI_TPM2_RESERVED1:
1955     case ACPI_TPM2_RESERVED3:
1956     case ACPI_TPM2_RESERVED4:
1957     case ACPI_TPM2_RESERVED5:
1958     case ACPI_TPM2_RESERVED9:
1959     case ACPI_TPM2_RESERVED10:
1960
1961         AcpiOsPrintf ("\n**** Reserved TPM2 Start Method type 0x%X\n",
1962             Tpm2Header->StartMethod);
1963         Status = AE_ERROR;
1964         break;
1965
1966     case ACPI_TPM2_NOT_ALLOWED:
1967     default:
1968
1969         AcpiOsPrintf ("\n**** Unknown TPM2 Start Method type 0x%X\n",
1970             Tpm2Header->StartMethod);
1971         Status = AE_ERROR;
1972         break;
1973     }
1974
1975     return (Status);
1976 }
1977
1978
1979 /******************************************************************************
1980  *
1981  * FUNCTION:    DtGetGenericTableInfo
1982  *
1983  * PARAMETERS:  Name                - Generic type name
1984  *
1985  * RETURN:      Info entry
1986  *
1987  * DESCRIPTION: Obtain table info for a generic name entry
1988  *
1989  *****************************************************************************/
1990
1991 ACPI_DMTABLE_INFO *
1992 DtGetGenericTableInfo (
1993     char                    *Name)
1994 {
1995     ACPI_DMTABLE_INFO       *Info;
1996     UINT32                  i;
1997
1998
1999     if (!Name)
2000     {
2001         return (NULL);
2002     }
2003
2004     /* Search info table for name match */
2005
2006     for (i = 0; ; i++)
2007     {
2008         Info = AcpiDmTableInfoGeneric[i];
2009         if (Info->Opcode == ACPI_DMT_EXIT)
2010         {
2011             Info = NULL;
2012             break;
2013         }
2014
2015         /* Use caseless compare for generic keywords */
2016
2017         if (!AcpiUtStricmp (Name, Info->Name))
2018         {
2019             break;
2020         }
2021     }
2022
2023     return (Info);
2024 }
2025
2026
2027 /******************************************************************************
2028  *
2029  * FUNCTION:    DtCompileUefi
2030  *
2031  * PARAMETERS:  List                - Current field list pointer
2032  *
2033  * RETURN:      Status
2034  *
2035  * DESCRIPTION: Compile UEFI.
2036  *
2037  *****************************************************************************/
2038
2039 ACPI_STATUS
2040 DtCompileUefi (
2041     void                    **List)
2042 {
2043     ACPI_STATUS             Status;
2044     DT_SUBTABLE             *Subtable;
2045     DT_SUBTABLE             *ParentTable;
2046     DT_FIELD                **PFieldList = (DT_FIELD **) List;
2047     UINT16                  *DataOffset;
2048
2049
2050     /* Compile the predefined portion of the UEFI table */
2051
2052     Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi,
2053         &Subtable, TRUE);
2054     if (ACPI_FAILURE (Status))
2055     {
2056         return (Status);
2057     }
2058
2059     DataOffset = (UINT16 *) (Subtable->Buffer + 16);
2060     *DataOffset = sizeof (ACPI_TABLE_UEFI);
2061
2062     ParentTable = DtPeekSubtable ();
2063     DtInsertSubtable (ParentTable, Subtable);
2064
2065     /*
2066      * Compile the "generic" portion of the UEFI table. This
2067      * part of the table is not predefined and any of the generic
2068      * operators may be used.
2069      */
2070     DtCompileGeneric ((void **) PFieldList, NULL, NULL);
2071     return (AE_OK);
2072 }
2073
2074
2075 /******************************************************************************
2076  *
2077  * FUNCTION:    DtCompileVrtc
2078  *
2079  * PARAMETERS:  List                - Current field list pointer
2080  *
2081  * RETURN:      Status
2082  *
2083  * DESCRIPTION: Compile VRTC.
2084  *
2085  *****************************************************************************/
2086
2087 ACPI_STATUS
2088 DtCompileVrtc (
2089     void                    **List)
2090 {
2091     ACPI_STATUS             Status;
2092
2093
2094     Status = DtCompileTwoSubtables (List,
2095         AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0);
2096     return (Status);
2097 }
2098
2099
2100 /******************************************************************************
2101  *
2102  * FUNCTION:    DtCompileWdat
2103  *
2104  * PARAMETERS:  List                - Current field list pointer
2105  *
2106  * RETURN:      Status
2107  *
2108  * DESCRIPTION: Compile WDAT.
2109  *
2110  *****************************************************************************/
2111
2112 ACPI_STATUS
2113 DtCompileWdat (
2114     void                    **List)
2115 {
2116     ACPI_STATUS             Status;
2117
2118
2119     Status = DtCompileTwoSubtables (List,
2120         AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0);
2121     return (Status);
2122 }
2123
2124
2125 /******************************************************************************
2126  *
2127  * FUNCTION:    DtCompileWpbt
2128  *
2129  * PARAMETERS:  List                - Current field list pointer
2130  *
2131  * RETURN:      Status
2132  *
2133  * DESCRIPTION: Compile WPBT.
2134  *
2135  *****************************************************************************/
2136
2137 ACPI_STATUS
2138 DtCompileWpbt (
2139     void                    **List)
2140 {
2141     DT_FIELD                **PFieldList = (DT_FIELD **) List;
2142     DT_SUBTABLE             *Subtable;
2143     DT_SUBTABLE             *ParentTable;
2144     ACPI_TABLE_WPBT         *Table;
2145     ACPI_STATUS             Status;
2146     UINT16                  Length;
2147
2148
2149     /* Compile the main table */
2150
2151     Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt,
2152         &Subtable, TRUE);
2153     if (ACPI_FAILURE (Status))
2154     {
2155         return (Status);
2156     }
2157
2158     ParentTable = DtPeekSubtable ();
2159     DtInsertSubtable (ParentTable, Subtable);
2160
2161     /* Compile the argument list subtable */
2162
2163     Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0,
2164         &Subtable, TRUE);
2165     if (ACPI_FAILURE (Status))
2166     {
2167         return (Status);
2168     }
2169
2170     /* Extract the length of the Arguments buffer, insert into main table */
2171
2172     Length = (UINT16) Subtable->TotalLength;
2173     Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
2174     Table->ArgumentsLength = Length;
2175
2176     ParentTable = DtPeekSubtable ();
2177     DtInsertSubtable (ParentTable, Subtable);
2178     return (AE_OK);
2179 }
2180
2181
2182 /******************************************************************************
2183  *
2184  * FUNCTION:    DtCompileXsdt
2185  *
2186  * PARAMETERS:  List                - Current field list pointer
2187  *
2188  * RETURN:      Status
2189  *
2190  * DESCRIPTION: Compile XSDT.
2191  *
2192  *****************************************************************************/
2193
2194 ACPI_STATUS
2195 DtCompileXsdt (
2196     void                    **List)
2197 {
2198     DT_SUBTABLE             *Subtable;
2199     DT_SUBTABLE             *ParentTable;
2200     DT_FIELD                *FieldList = *(DT_FIELD **) List;
2201     UINT64                  Address;
2202
2203
2204     ParentTable = DtPeekSubtable ();
2205
2206     while (FieldList)
2207     {
2208         DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO);
2209
2210         DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable);
2211         DtInsertSubtable (ParentTable, Subtable);
2212         FieldList = FieldList->Next;
2213     }
2214
2215     return (AE_OK);
2216 }
2217
2218
2219 /******************************************************************************
2220  *
2221  * FUNCTION:    DtCompileGeneric
2222  *
2223  * PARAMETERS:  List                - Current field list pointer
2224  *              Name                - Field name to end generic compiling
2225  *              Length              - Compiled table length to return
2226  *
2227  * RETURN:      Status
2228  *
2229  * DESCRIPTION: Compile generic unknown table.
2230  *
2231  *****************************************************************************/
2232
2233 ACPI_STATUS
2234 DtCompileGeneric (
2235     void                    **List,
2236     char                    *Name,
2237     UINT32                  *Length)
2238 {
2239     ACPI_STATUS             Status;
2240     DT_SUBTABLE             *Subtable;
2241     DT_SUBTABLE             *ParentTable;
2242     DT_FIELD                **PFieldList = (DT_FIELD **) List;
2243     ACPI_DMTABLE_INFO       *Info;
2244
2245
2246     ParentTable = DtPeekSubtable ();
2247
2248     /*
2249      * Compile the "generic" portion of the table. This
2250      * part of the table is not predefined and any of the generic
2251      * operators may be used.
2252      */
2253
2254     /* Find any and all labels in the entire generic portion */
2255
2256     DtDetectAllLabels (*PFieldList);
2257
2258     /* Now we can actually compile the parse tree */
2259
2260     if (Length && *Length)
2261     {
2262         *Length = 0;
2263     }
2264     while (*PFieldList)
2265     {
2266         if (Name && !strcmp ((*PFieldList)->Name, Name))
2267         {
2268             break;
2269         }
2270
2271         Info = DtGetGenericTableInfo ((*PFieldList)->Name);
2272         if (!Info)
2273         {
2274             sprintf (MsgBuffer, "Generic data type \"%s\" not found",
2275                 (*PFieldList)->Name);
2276             DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2277                 (*PFieldList), MsgBuffer);
2278
2279             *PFieldList = (*PFieldList)->Next;
2280             continue;
2281         }
2282
2283         Status = DtCompileTable (PFieldList, Info,
2284             &Subtable, TRUE);
2285         if (ACPI_SUCCESS (Status))
2286         {
2287             DtInsertSubtable (ParentTable, Subtable);
2288             if (Length)
2289             {
2290                 *Length += Subtable->Length;
2291             }
2292         }
2293         else
2294         {
2295             *PFieldList = (*PFieldList)->Next;
2296
2297             if (Status == AE_NOT_FOUND)
2298             {
2299                 sprintf (MsgBuffer, "Generic data type \"%s\" not found",
2300                     (*PFieldList)->Name);
2301                 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2302                     (*PFieldList), MsgBuffer);
2303             }
2304         }
2305     }
2306
2307     return (AE_OK);
2308 }