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 - 2021, 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 "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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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:    DtCompileNfit
580  *
581  * PARAMETERS:  List                - Current field list pointer
582  *
583  * RETURN:      Status
584  *
585  * DESCRIPTION: Compile NFIT.
586  *
587  *****************************************************************************/
588 
589 ACPI_STATUS
590 DtCompileNfit (
591     void                    **List)
592 {
593     ACPI_STATUS             Status;
594     DT_SUBTABLE             *Subtable;
595     DT_SUBTABLE             *ParentTable;
596     DT_FIELD                **PFieldList = (DT_FIELD **) List;
597     DT_FIELD                *SubtableStart;
598     ACPI_NFIT_HEADER        *NfitHeader;
599     ACPI_DMTABLE_INFO       *InfoTable;
600     UINT32                  Count;
601     ACPI_NFIT_INTERLEAVE    *Interleave = NULL;
602     ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
603 
604 
605     /* Main table */
606 
607     Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit,
608         &Subtable);
609     if (ACPI_FAILURE (Status))
610     {
611         return (Status);
612     }
613 
614     ParentTable = DtPeekSubtable ();
615     DtInsertSubtable (ParentTable, Subtable);
616     DtPushSubtable (Subtable);
617 
618     /* Subtables */
619 
620     while (*PFieldList)
621     {
622         SubtableStart = *PFieldList;
623         Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr,
624             &Subtable);
625         if (ACPI_FAILURE (Status))
626         {
627             return (Status);
628         }
629 
630         ParentTable = DtPeekSubtable ();
631         DtInsertSubtable (ParentTable, Subtable);
632         DtPushSubtable (Subtable);
633 
634         NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
635 
636         switch (NfitHeader->Type)
637         {
638         case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
639 
640             InfoTable = AcpiDmTableInfoNfit0;
641             break;
642 
643         case ACPI_NFIT_TYPE_MEMORY_MAP:
644 
645             InfoTable = AcpiDmTableInfoNfit1;
646             break;
647 
648         case ACPI_NFIT_TYPE_INTERLEAVE:
649 
650             Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer);
651             InfoTable = AcpiDmTableInfoNfit2;
652             break;
653 
654         case ACPI_NFIT_TYPE_SMBIOS:
655 
656             InfoTable = AcpiDmTableInfoNfit3;
657             break;
658 
659         case ACPI_NFIT_TYPE_CONTROL_REGION:
660 
661             InfoTable = AcpiDmTableInfoNfit4;
662             break;
663 
664         case ACPI_NFIT_TYPE_DATA_REGION:
665 
666             InfoTable = AcpiDmTableInfoNfit5;
667             break;
668 
669         case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
670 
671             Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer);
672             InfoTable = AcpiDmTableInfoNfit6;
673             break;
674 
675         case ACPI_NFIT_TYPE_CAPABILITIES:
676 
677             InfoTable = AcpiDmTableInfoNfit7;
678             break;
679 
680         default:
681 
682             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT");
683             return (AE_ERROR);
684         }
685 
686         Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
687         if (ACPI_FAILURE (Status))
688         {
689             return (Status);
690         }
691 
692         ParentTable = DtPeekSubtable ();
693         DtInsertSubtable (ParentTable, Subtable);
694         DtPopSubtable ();
695 
696         switch (NfitHeader->Type)
697         {
698         case ACPI_NFIT_TYPE_INTERLEAVE:
699 
700             Count = 0;
701             DtPushSubtable (Subtable);
702             while (*PFieldList)
703             {
704                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a,
705                     &Subtable);
706                 if (ACPI_FAILURE (Status))
707                 {
708                     return (Status);
709                 }
710 
711                 if (!Subtable)
712                 {
713                     DtPopSubtable ();
714                     break;
715                 }
716 
717                 ParentTable = DtPeekSubtable ();
718                 DtInsertSubtable (ParentTable, Subtable);
719                 Count++;
720             }
721 
722             Interleave->LineCount = Count;
723             break;
724 
725         case ACPI_NFIT_TYPE_SMBIOS:
726 
727             if (*PFieldList)
728             {
729                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a,
730                     &Subtable);
731                 if (ACPI_FAILURE (Status))
732                 {
733                     return (Status);
734                 }
735 
736                 if (Subtable)
737                 {
738                     DtInsertSubtable (ParentTable, Subtable);
739                 }
740             }
741             break;
742 
743         case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
744 
745             Count = 0;
746             DtPushSubtable (Subtable);
747             while (*PFieldList)
748             {
749                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a,
750                     &Subtable);
751                 if (ACPI_FAILURE (Status))
752                 {
753                     return (Status);
754                 }
755 
756                 if (!Subtable)
757                 {
758                     DtPopSubtable ();
759                     break;
760                 }
761 
762                 ParentTable = DtPeekSubtable ();
763                 DtInsertSubtable (ParentTable, Subtable);
764                 Count++;
765             }
766 
767             Hint->HintCount = (UINT16) Count;
768             break;
769 
770         default:
771             break;
772         }
773     }
774 
775     return (AE_OK);
776 }
777 
778 
779 /******************************************************************************
780  *
781  * FUNCTION:    DtCompilePcct
782  *
783  * PARAMETERS:  List                - Current field list pointer
784  *
785  * RETURN:      Status
786  *
787  * DESCRIPTION: Compile PCCT.
788  *
789  *****************************************************************************/
790 
791 ACPI_STATUS
792 DtCompilePcct (
793     void                    **List)
794 {
795     ACPI_STATUS             Status;
796     DT_SUBTABLE             *Subtable;
797     DT_SUBTABLE             *ParentTable;
798     DT_FIELD                **PFieldList = (DT_FIELD **) List;
799     DT_FIELD                *SubtableStart;
800     ACPI_SUBTABLE_HEADER    *PcctHeader;
801     ACPI_DMTABLE_INFO       *InfoTable;
802 
803 
804     /* Main table */
805 
806     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct,
807         &Subtable);
808     if (ACPI_FAILURE (Status))
809     {
810         return (Status);
811     }
812 
813     ParentTable = DtPeekSubtable ();
814     DtInsertSubtable (ParentTable, Subtable);
815 
816     /* Subtables */
817 
818     while (*PFieldList)
819     {
820         SubtableStart = *PFieldList;
821         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr,
822             &Subtable);
823         if (ACPI_FAILURE (Status))
824         {
825             return (Status);
826         }
827 
828         ParentTable = DtPeekSubtable ();
829         DtInsertSubtable (ParentTable, Subtable);
830         DtPushSubtable (Subtable);
831 
832         PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
833 
834         switch (PcctHeader->Type)
835         {
836         case ACPI_PCCT_TYPE_GENERIC_SUBSPACE:
837 
838             InfoTable = AcpiDmTableInfoPcct0;
839             break;
840 
841         case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE:
842 
843             InfoTable = AcpiDmTableInfoPcct1;
844             break;
845 
846         case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2:
847 
848             InfoTable = AcpiDmTableInfoPcct2;
849             break;
850 
851         case ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE:
852 
853             InfoTable = AcpiDmTableInfoPcct3;
854             break;
855 
856         case ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE:
857 
858             InfoTable = AcpiDmTableInfoPcct4;
859             break;
860 
861         default:
862 
863             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT");
864             return (AE_ERROR);
865         }
866 
867         Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
868         if (ACPI_FAILURE (Status))
869         {
870             return (Status);
871         }
872 
873         ParentTable = DtPeekSubtable ();
874         DtInsertSubtable (ParentTable, Subtable);
875         DtPopSubtable ();
876     }
877 
878     return (AE_OK);
879 }
880 
881 
882 /******************************************************************************
883  *
884  * FUNCTION:    DtCompilePdtt
885  *
886  * PARAMETERS:  List                - Current field list pointer
887  *
888  * RETURN:      Status
889  *
890  * DESCRIPTION: Compile PDTT.
891  *
892  *****************************************************************************/
893 
894 ACPI_STATUS
895 DtCompilePdtt (
896     void                    **List)
897 {
898     ACPI_STATUS             Status;
899     DT_SUBTABLE             *Subtable;
900     DT_SUBTABLE             *ParentTable;
901     DT_FIELD                **PFieldList = (DT_FIELD **) List;
902     ACPI_TABLE_PDTT         *PdttHeader;
903     UINT32                  Count = 0;
904 
905 
906     /* Main table */
907 
908     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt, &Subtable);
909     if (ACPI_FAILURE (Status))
910     {
911         return (Status);
912     }
913 
914     ParentTable = DtPeekSubtable ();
915     DtInsertSubtable (ParentTable, Subtable);
916 
917     PdttHeader = ACPI_CAST_PTR (ACPI_TABLE_PDTT, ParentTable->Buffer);
918     PdttHeader->ArrayOffset = sizeof (ACPI_TABLE_PDTT);
919 
920     /* There is only one type of subtable at this time, no need to decode */
921 
922     while (*PFieldList)
923     {
924         /* List of subchannel IDs, each 2 bytes */
925 
926         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt0,
927             &Subtable);
928         if (ACPI_FAILURE (Status))
929         {
930             return (Status);
931         }
932 
933         DtInsertSubtable (ParentTable, Subtable);
934         Count++;
935     }
936 
937     PdttHeader->TriggerCount = (UINT8) Count;
938     return (AE_OK);
939 }
940 
941 
942 /******************************************************************************
943  *
944  * FUNCTION:    DtCompilePmtt
945  *
946  * PARAMETERS:  List                - Current field list pointer
947  *
948  * RETURN:      Status
949  *
950  * DESCRIPTION: Compile PMTT.
951  *
952  *****************************************************************************/
953 
954 ACPI_STATUS
955 DtCompilePmtt (
956     void                    **List)
957 {
958     ACPI_STATUS             Status;
959     DT_SUBTABLE             *Subtable;
960     DT_SUBTABLE             *ParentTable;
961     DT_FIELD                **PFieldList = (DT_FIELD **) List;
962     DT_FIELD                *SubtableStart;
963     ACPI_PMTT_HEADER        *PmttHeader;
964     ACPI_PMTT_CONTROLLER    *PmttController;
965     UINT16                  DomainCount;
966     UINT8                   PrevType = ACPI_PMTT_TYPE_SOCKET;
967 
968 
969     /* Main table */
970 
971     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable);
972     if (ACPI_FAILURE (Status))
973     {
974         return (Status);
975     }
976 
977     ParentTable = DtPeekSubtable ();
978     DtInsertSubtable (ParentTable, Subtable);
979     DtPushSubtable (Subtable);
980 
981     while (*PFieldList)
982     {
983         SubtableStart = *PFieldList;
984         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr,
985             &Subtable);
986         if (ACPI_FAILURE (Status))
987         {
988             return (Status);
989         }
990 
991         PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer);
992         while (PrevType >= PmttHeader->Type)
993         {
994             DtPopSubtable ();
995 
996             if (PrevType == ACPI_PMTT_TYPE_SOCKET)
997             {
998                 break;
999             }
1000 
1001             PrevType--;
1002         }
1003 
1004         PrevType = PmttHeader->Type;
1005 
1006         ParentTable = DtPeekSubtable ();
1007         DtInsertSubtable (ParentTable, Subtable);
1008         DtPushSubtable (Subtable);
1009 
1010         switch (PmttHeader->Type)
1011         {
1012         case ACPI_PMTT_TYPE_SOCKET:
1013 
1014             /* Subtable: Socket Structure */
1015 
1016             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0,
1017                 &Subtable);
1018             if (ACPI_FAILURE (Status))
1019             {
1020                 return (Status);
1021             }
1022 
1023             ParentTable = DtPeekSubtable ();
1024             DtInsertSubtable (ParentTable, Subtable);
1025             break;
1026 
1027         case ACPI_PMTT_TYPE_CONTROLLER:
1028 
1029             /* Subtable: Memory Controller Structure */
1030 
1031             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1,
1032                 &Subtable);
1033             if (ACPI_FAILURE (Status))
1034             {
1035                 return (Status);
1036             }
1037 
1038             ParentTable = DtPeekSubtable ();
1039             DtInsertSubtable (ParentTable, Subtable);
1040 
1041             PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER,
1042                 (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER)));
1043             DomainCount = PmttController->DomainCount;
1044 
1045             while (DomainCount)
1046             {
1047                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a,
1048                     &Subtable);
1049                 if (ACPI_FAILURE (Status))
1050                 {
1051                     return (Status);
1052                 }
1053 
1054                 DtInsertSubtable (ParentTable, Subtable);
1055                 DomainCount--;
1056             }
1057             break;
1058 
1059         case ACPI_PMTT_TYPE_DIMM:
1060 
1061             /* Subtable: Physical Component Structure */
1062 
1063             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2,
1064                 &Subtable);
1065             if (ACPI_FAILURE (Status))
1066             {
1067                 return (Status);
1068             }
1069 
1070             ParentTable = DtPeekSubtable ();
1071             DtInsertSubtable (ParentTable, Subtable);
1072             break;
1073 
1074         default:
1075 
1076             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT");
1077             return (AE_ERROR);
1078         }
1079     }
1080 
1081     return (Status);
1082 }
1083 
1084 
1085 /******************************************************************************
1086  *
1087  * FUNCTION:    DtCompilePptt
1088  *
1089  * PARAMETERS:  List                - Current field list pointer
1090  *
1091  * RETURN:      Status
1092  *
1093  * DESCRIPTION: Compile PPTT.
1094  *
1095  *****************************************************************************/
1096 
1097 ACPI_STATUS
1098 DtCompilePptt (
1099     void                    **List)
1100 {
1101     ACPI_STATUS             Status;
1102     ACPI_SUBTABLE_HEADER    *PpttHeader;
1103     ACPI_PPTT_PROCESSOR     *PpttProcessor = NULL;
1104     DT_SUBTABLE             *Subtable;
1105     DT_SUBTABLE             *ParentTable;
1106     ACPI_DMTABLE_INFO       *InfoTable;
1107     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1108     DT_FIELD                *SubtableStart;
1109 
1110 
1111     ParentTable = DtPeekSubtable ();
1112     while (*PFieldList)
1113     {
1114         SubtableStart = *PFieldList;
1115 
1116         /* Compile PPTT subtable header */
1117 
1118         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPpttHdr,
1119             &Subtable);
1120         if (ACPI_FAILURE (Status))
1121         {
1122             return (Status);
1123         }
1124         DtInsertSubtable (ParentTable, Subtable);
1125         PpttHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1126         PpttHeader->Length = (UINT8)(Subtable->Length);
1127 
1128         switch (PpttHeader->Type)
1129         {
1130         case ACPI_PPTT_TYPE_PROCESSOR:
1131 
1132             InfoTable = AcpiDmTableInfoPptt0;
1133             break;
1134 
1135         case ACPI_PPTT_TYPE_CACHE:
1136 
1137             InfoTable = AcpiDmTableInfoPptt1;
1138             break;
1139 
1140         case ACPI_PPTT_TYPE_ID:
1141 
1142             InfoTable = AcpiDmTableInfoPptt2;
1143             break;
1144 
1145         default:
1146 
1147             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PPTT");
1148             return (AE_ERROR);
1149         }
1150 
1151         /* Compile PPTT subtable body */
1152 
1153         Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1154         if (ACPI_FAILURE (Status))
1155         {
1156             return (Status);
1157         }
1158         DtInsertSubtable (ParentTable, Subtable);
1159         PpttHeader->Length += (UINT8)(Subtable->Length);
1160 
1161         /* Compile PPTT subtable additionals */
1162 
1163         switch (PpttHeader->Type)
1164         {
1165         case ACPI_PPTT_TYPE_PROCESSOR:
1166 
1167             PpttProcessor = ACPI_SUB_PTR (ACPI_PPTT_PROCESSOR,
1168                 Subtable->Buffer, sizeof (ACPI_SUBTABLE_HEADER));
1169             if (PpttProcessor)
1170             {
1171                 /* Compile initiator proximity domain list */
1172 
1173                 PpttProcessor->NumberOfPrivResources = 0;
1174                 while (*PFieldList)
1175                 {
1176                     Status = DtCompileTable (PFieldList,
1177                         AcpiDmTableInfoPptt0a, &Subtable);
1178                     if (ACPI_FAILURE (Status))
1179                     {
1180                         return (Status);
1181                     }
1182                     if (!Subtable)
1183                     {
1184                         break;
1185                     }
1186 
1187                     DtInsertSubtable (ParentTable, Subtable);
1188                     PpttHeader->Length += (UINT8)(Subtable->Length);
1189                     PpttProcessor->NumberOfPrivResources++;
1190                 }
1191             }
1192             break;
1193 
1194         default:
1195 
1196             break;
1197         }
1198     }
1199 
1200     return (AE_OK);
1201 }
1202 
1203 
1204 /******************************************************************************
1205  *
1206  * FUNCTION:    DtCompileRsdt
1207  *
1208  * PARAMETERS:  List                - Current field list pointer
1209  *
1210  * RETURN:      Status
1211  *
1212  * DESCRIPTION: Compile RSDT.
1213  *
1214  *****************************************************************************/
1215 
1216 ACPI_STATUS
1217 DtCompileRsdt (
1218     void                    **List)
1219 {
1220     DT_SUBTABLE             *Subtable;
1221     DT_SUBTABLE             *ParentTable;
1222     DT_FIELD                *FieldList = *(DT_FIELD **) List;
1223     UINT32                  Address;
1224 
1225 
1226     ParentTable = DtPeekSubtable ();
1227 
1228     while (FieldList)
1229     {
1230         DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO);
1231 
1232         DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable);
1233         DtInsertSubtable (ParentTable, Subtable);
1234         FieldList = FieldList->Next;
1235     }
1236 
1237     return (AE_OK);
1238 }
1239 
1240 
1241 /******************************************************************************
1242  *
1243  * FUNCTION:    DtCompileS3pt
1244  *
1245  * PARAMETERS:  PFieldList          - Current field list pointer
1246  *
1247  * RETURN:      Status
1248  *
1249  * DESCRIPTION: Compile S3PT (Pointed to by FPDT)
1250  *
1251  *****************************************************************************/
1252 
1253 ACPI_STATUS
1254 DtCompileS3pt (
1255     DT_FIELD                **PFieldList)
1256 {
1257     ACPI_STATUS             Status;
1258     ACPI_FPDT_HEADER        *S3ptHeader;
1259     DT_SUBTABLE             *Subtable;
1260     DT_SUBTABLE             *ParentTable;
1261     ACPI_DMTABLE_INFO       *InfoTable;
1262     DT_FIELD                *SubtableStart;
1263 
1264 
1265     Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt,
1266         &AslGbl_RootTable);
1267     if (ACPI_FAILURE (Status))
1268     {
1269         return (Status);
1270     }
1271 
1272     DtPushSubtable (AslGbl_RootTable);
1273 
1274     while (*PFieldList)
1275     {
1276         SubtableStart = *PFieldList;
1277         Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr,
1278             &Subtable);
1279         if (ACPI_FAILURE (Status))
1280         {
1281             return (Status);
1282         }
1283 
1284         ParentTable = DtPeekSubtable ();
1285         DtInsertSubtable (ParentTable, Subtable);
1286         DtPushSubtable (Subtable);
1287 
1288         S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
1289 
1290         switch (S3ptHeader->Type)
1291         {
1292         case ACPI_S3PT_TYPE_RESUME:
1293 
1294             InfoTable = AcpiDmTableInfoS3pt0;
1295             break;
1296 
1297         case ACPI_S3PT_TYPE_SUSPEND:
1298 
1299             InfoTable = AcpiDmTableInfoS3pt1;
1300             break;
1301 
1302         default:
1303 
1304             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT");
1305             return (AE_ERROR);
1306         }
1307 
1308         Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1309         if (ACPI_FAILURE (Status))
1310         {
1311             return (Status);
1312         }
1313 
1314         ParentTable = DtPeekSubtable ();
1315         DtInsertSubtable (ParentTable, Subtable);
1316         DtPopSubtable ();
1317     }
1318 
1319     return (AE_OK);
1320 }
1321 
1322 
1323 /******************************************************************************
1324  *
1325  * FUNCTION:    DtCompileSdev
1326  *
1327  * PARAMETERS:  List                - Current field list pointer
1328  *
1329  * RETURN:      Status
1330  *
1331  * DESCRIPTION: Compile SDEV.
1332  *
1333  *****************************************************************************/
1334 
1335 ACPI_STATUS
1336 DtCompileSdev (
1337     void                    **List)
1338 {
1339     ACPI_STATUS             Status;
1340     ACPI_SDEV_HEADER        *SdevHeader;
1341     DT_SUBTABLE             *Subtable;
1342     DT_SUBTABLE             *ParentTable;
1343     ACPI_DMTABLE_INFO       *InfoTable;
1344     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1345     DT_FIELD                *SubtableStart;
1346     ACPI_SDEV_PCIE          *Pcie = NULL;
1347     ACPI_SDEV_NAMESPACE     *Namesp = NULL;
1348     UINT32                  EntryCount;
1349 
1350 
1351     /* Subtables */
1352 
1353     while (*PFieldList)
1354     {
1355         /* Compile common SDEV subtable header */
1356 
1357         SubtableStart = *PFieldList;
1358         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevHdr,
1359             &Subtable);
1360         if (ACPI_FAILURE (Status))
1361         {
1362             return (Status);
1363         }
1364 
1365         ParentTable = DtPeekSubtable ();
1366         DtInsertSubtable (ParentTable, Subtable);
1367         DtPushSubtable (Subtable);
1368 
1369         SdevHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer);
1370         SdevHeader->Length = (UINT8)(sizeof (ACPI_SDEV_HEADER));
1371 
1372         switch (SdevHeader->Type)
1373         {
1374         case ACPI_SDEV_TYPE_NAMESPACE_DEVICE:
1375 
1376             InfoTable = AcpiDmTableInfoSdev0;
1377             Namesp = ACPI_CAST_PTR (ACPI_SDEV_NAMESPACE, Subtable->Buffer);
1378             break;
1379 
1380         case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
1381 
1382             InfoTable = AcpiDmTableInfoSdev1;
1383             Pcie = ACPI_CAST_PTR (ACPI_SDEV_PCIE, Subtable->Buffer);
1384             break;
1385 
1386         default:
1387 
1388             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV");
1389             return (AE_ERROR);
1390         }
1391 
1392         /* Compile SDEV subtable body */
1393 
1394         Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1395         if (ACPI_FAILURE (Status))
1396         {
1397             return (Status);
1398         }
1399 
1400         ParentTable = DtPeekSubtable ();
1401         DtInsertSubtable (ParentTable, Subtable);
1402 
1403         /* Optional data fields are appended to the main subtable body */
1404 
1405         switch (SdevHeader->Type)
1406         {
1407         case ACPI_SDEV_TYPE_NAMESPACE_DEVICE:
1408 
1409             /* Append DeviceId namespace string */
1410 
1411             Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0a,
1412                 &Subtable);
1413             if (ACPI_FAILURE (Status))
1414             {
1415                 return (Status);
1416             }
1417 
1418             if (!Subtable)
1419             {
1420                 break;
1421             }
1422 
1423             ParentTable = DtPeekSubtable ();
1424             DtInsertSubtable (ParentTable, Subtable);
1425 
1426             Namesp->DeviceIdOffset = sizeof (ACPI_SDEV_NAMESPACE);
1427             Namesp->DeviceIdLength = (UINT16) Subtable->Length;
1428 
1429             /* Append Vendor data */
1430 
1431             Namesp->VendorDataLength = 0;
1432             Namesp->VendorDataOffset = 0;
1433 
1434             if (*PFieldList)
1435             {
1436                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b,
1437                     &Subtable);
1438                 if (ACPI_FAILURE (Status))
1439                 {
1440                     return (Status);
1441                 }
1442 
1443                 if (Subtable)
1444                 {
1445                     ParentTable = DtPeekSubtable ();
1446                     DtInsertSubtable (ParentTable, Subtable);
1447 
1448                     Namesp->VendorDataOffset =
1449                         Namesp->DeviceIdOffset + Namesp->DeviceIdLength;
1450                     Namesp->VendorDataLength =
1451                         (UINT16) Subtable->Length;
1452 
1453                     /* Final size of entire namespace structure */
1454 
1455                     SdevHeader->Length = (UINT16)(sizeof(ACPI_SDEV_NAMESPACE) +
1456                         Subtable->Length + Namesp->DeviceIdLength);
1457                 }
1458             }
1459 
1460             break;
1461 
1462         case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
1463 
1464             /* Append the PCIe path info first */
1465 
1466             EntryCount = 0;
1467             while (*PFieldList && !strcmp ((*PFieldList)->Name, "Device"))
1468             {
1469                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1a,
1470                     &Subtable);
1471                 if (ACPI_FAILURE (Status))
1472                 {
1473                     return (Status);
1474                 }
1475 
1476                 if (!Subtable)
1477                 {
1478                     DtPopSubtable ();
1479                     break;
1480                 }
1481 
1482                 ParentTable = DtPeekSubtable ();
1483                 DtInsertSubtable (ParentTable, Subtable);
1484                 EntryCount++;
1485             }
1486 
1487             /* Path offset will point immediately after the main subtable */
1488 
1489             Pcie->PathOffset = sizeof (ACPI_SDEV_PCIE);
1490             Pcie->PathLength = (UINT16)
1491                 (EntryCount * sizeof (ACPI_SDEV_PCIE_PATH));
1492 
1493             /* Append the Vendor Data last */
1494 
1495             Pcie->VendorDataLength = 0;
1496             Pcie->VendorDataOffset = 0;
1497 
1498             if (*PFieldList)
1499             {
1500                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b,
1501                     &Subtable);
1502                 if (ACPI_FAILURE (Status))
1503                 {
1504                     return (Status);
1505                 }
1506 
1507                 if (Subtable)
1508                 {
1509                     ParentTable = DtPeekSubtable ();
1510                     DtInsertSubtable (ParentTable, Subtable);
1511 
1512                     Pcie->VendorDataOffset =
1513                         Pcie->PathOffset + Pcie->PathLength;
1514                     Pcie->VendorDataLength = (UINT16)
1515                         Subtable->Length;
1516                 }
1517             }
1518 
1519             SdevHeader->Length =
1520                 sizeof (ACPI_SDEV_PCIE) +
1521                 Pcie->PathLength + Pcie->VendorDataLength;
1522             break;
1523 
1524         default:
1525 
1526             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV");
1527             return (AE_ERROR);
1528         }
1529 
1530         DtPopSubtable ();
1531     }
1532 
1533     return (AE_OK);
1534 }
1535 
1536 
1537 /******************************************************************************
1538  *
1539  * FUNCTION:    DtCompileSlic
1540  *
1541  * PARAMETERS:  List                - Current field list pointer
1542  *
1543  * RETURN:      Status
1544  *
1545  * DESCRIPTION: Compile SLIC.
1546  *
1547  *****************************************************************************/
1548 
1549 ACPI_STATUS
1550 DtCompileSlic (
1551     void                    **List)
1552 {
1553     ACPI_STATUS             Status;
1554     DT_SUBTABLE             *Subtable;
1555     DT_SUBTABLE             *ParentTable;
1556     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1557 
1558 
1559     while (*PFieldList)
1560     {
1561         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic,
1562             &Subtable);
1563         if (ACPI_FAILURE (Status))
1564         {
1565             return (Status);
1566         }
1567 
1568         ParentTable = DtPeekSubtable ();
1569         DtInsertSubtable (ParentTable, Subtable);
1570         DtPushSubtable (Subtable);
1571         DtPopSubtable ();
1572     }
1573 
1574     return (AE_OK);
1575 }
1576 
1577 
1578 /******************************************************************************
1579  *
1580  * FUNCTION:    DtCompileSlit
1581  *
1582  * PARAMETERS:  List                - Current field list pointer
1583  *
1584  * RETURN:      Status
1585  *
1586  * DESCRIPTION: Compile SLIT.
1587  *
1588  *****************************************************************************/
1589 
1590 ACPI_STATUS
1591 DtCompileSlit (
1592     void                    **List)
1593 {
1594     ACPI_STATUS             Status;
1595     DT_SUBTABLE             *Subtable;
1596     DT_SUBTABLE             *ParentTable;
1597     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1598     DT_FIELD                *FieldList;
1599     DT_FIELD                *EndOfFieldList = NULL;
1600     UINT32                  Localities;
1601     UINT32                  LocalityListLength;
1602     UINT8                   *LocalityBuffer;
1603 
1604 
1605     Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
1606         &Subtable);
1607     if (ACPI_FAILURE (Status))
1608     {
1609         return (Status);
1610     }
1611 
1612     ParentTable = DtPeekSubtable ();
1613     DtInsertSubtable (ParentTable, Subtable);
1614 
1615     Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
1616     LocalityBuffer = UtLocalCalloc (Localities);
1617     LocalityListLength = 0;
1618 
1619     /* Compile each locality buffer */
1620 
1621     FieldList = *PFieldList;
1622     while (FieldList)
1623     {
1624         DtCompileBuffer (LocalityBuffer,
1625             FieldList->Value, FieldList, Localities);
1626 
1627         LocalityListLength++;
1628         DtCreateSubtable (LocalityBuffer, Localities, &Subtable);
1629         DtInsertSubtable (ParentTable, Subtable);
1630         EndOfFieldList = FieldList;
1631         FieldList = FieldList->Next;
1632     }
1633 
1634     if (LocalityListLength != Localities)
1635     {
1636         sprintf(AslGbl_MsgBuffer,
1637             "Found %u entries, must match LocalityCount: %u",
1638             LocalityListLength, Localities);
1639         DtError (ASL_ERROR, ASL_MSG_ENTRY_LIST, EndOfFieldList, AslGbl_MsgBuffer);
1640         ACPI_FREE (LocalityBuffer);
1641         return (AE_LIMIT);
1642     }
1643 
1644     ACPI_FREE (LocalityBuffer);
1645     return (AE_OK);
1646 }
1647 
1648 
1649 /******************************************************************************
1650  *
1651  * FUNCTION:    DtCompileSrat
1652  *
1653  * PARAMETERS:  List                - Current field list pointer
1654  *
1655  * RETURN:      Status
1656  *
1657  * DESCRIPTION: Compile SRAT.
1658  *
1659  *****************************************************************************/
1660 
1661 ACPI_STATUS
1662 DtCompileSrat (
1663     void                    **List)
1664 {
1665     ACPI_STATUS             Status;
1666     DT_SUBTABLE             *Subtable;
1667     DT_SUBTABLE             *ParentTable;
1668     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1669     DT_FIELD                *SubtableStart;
1670     ACPI_SUBTABLE_HEADER    *SratHeader;
1671     ACPI_DMTABLE_INFO       *InfoTable;
1672 
1673 
1674     Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat,
1675         &Subtable);
1676     if (ACPI_FAILURE (Status))
1677     {
1678         return (Status);
1679     }
1680 
1681     ParentTable = DtPeekSubtable ();
1682     DtInsertSubtable (ParentTable, Subtable);
1683 
1684     while (*PFieldList)
1685     {
1686         SubtableStart = *PFieldList;
1687         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr,
1688             &Subtable);
1689         if (ACPI_FAILURE (Status))
1690         {
1691             return (Status);
1692         }
1693 
1694         ParentTable = DtPeekSubtable ();
1695         DtInsertSubtable (ParentTable, Subtable);
1696         DtPushSubtable (Subtable);
1697 
1698         SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1699 
1700         switch (SratHeader->Type)
1701         {
1702         case ACPI_SRAT_TYPE_CPU_AFFINITY:
1703 
1704             InfoTable = AcpiDmTableInfoSrat0;
1705             break;
1706 
1707         case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
1708 
1709             InfoTable = AcpiDmTableInfoSrat1;
1710             break;
1711 
1712         case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
1713 
1714             InfoTable = AcpiDmTableInfoSrat2;
1715             break;
1716 
1717         case ACPI_SRAT_TYPE_GICC_AFFINITY:
1718 
1719             InfoTable = AcpiDmTableInfoSrat3;
1720             break;
1721 
1722         case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
1723 
1724             InfoTable = AcpiDmTableInfoSrat4;
1725             break;
1726 
1727         case ACPI_SRAT_TYPE_GENERIC_AFFINITY:
1728 
1729             InfoTable = AcpiDmTableInfoSrat5;
1730             break;
1731 
1732         default:
1733 
1734             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT");
1735             return (AE_ERROR);
1736         }
1737 
1738         Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1739         if (ACPI_FAILURE (Status))
1740         {
1741             return (Status);
1742         }
1743 
1744         ParentTable = DtPeekSubtable ();
1745         DtInsertSubtable (ParentTable, Subtable);
1746         DtPopSubtable ();
1747     }
1748 
1749     return (AE_OK);
1750 }
1751 
1752 
1753 /******************************************************************************
1754  *
1755  * FUNCTION:    DtCompileStao
1756  *
1757  * PARAMETERS:  PFieldList          - Current field list pointer
1758  *
1759  * RETURN:      Status
1760  *
1761  * DESCRIPTION: Compile STAO.
1762  *
1763  *****************************************************************************/
1764 
1765 ACPI_STATUS
1766 DtCompileStao (
1767     void                    **List)
1768 {
1769     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1770     DT_SUBTABLE             *Subtable;
1771     DT_SUBTABLE             *ParentTable;
1772     ACPI_STATUS             Status;
1773 
1774 
1775     /* Compile the main table */
1776 
1777     Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao,
1778         &Subtable);
1779     if (ACPI_FAILURE (Status))
1780     {
1781         return (Status);
1782     }
1783 
1784     ParentTable = DtPeekSubtable ();
1785     DtInsertSubtable (ParentTable, Subtable);
1786 
1787     /* Compile each ASCII namestring as a subtable */
1788 
1789     while (*PFieldList)
1790     {
1791         Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr,
1792             &Subtable);
1793         if (ACPI_FAILURE (Status))
1794         {
1795             return (Status);
1796         }
1797 
1798         ParentTable = DtPeekSubtable ();
1799         DtInsertSubtable (ParentTable, Subtable);
1800     }
1801 
1802     return (AE_OK);
1803 }
1804 
1805 
1806 /******************************************************************************
1807  *
1808  * FUNCTION:    DtCompileTcpa
1809  *
1810  * PARAMETERS:  PFieldList          - Current field list pointer
1811  *
1812  * RETURN:      Status
1813  *
1814  * DESCRIPTION: Compile TCPA.
1815  *
1816  *****************************************************************************/
1817 
1818 ACPI_STATUS
1819 DtCompileTcpa (
1820     void                    **List)
1821 {
1822     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1823     DT_SUBTABLE             *Subtable;
1824     ACPI_TABLE_TCPA_HDR     *TcpaHeader;
1825     DT_SUBTABLE             *ParentTable;
1826     ACPI_STATUS             Status;
1827 
1828 
1829     /* Compile the main table */
1830 
1831     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr,
1832         &Subtable);
1833     if (ACPI_FAILURE (Status))
1834     {
1835         return (Status);
1836     }
1837 
1838     ParentTable = DtPeekSubtable ();
1839     DtInsertSubtable (ParentTable, Subtable);
1840 
1841     /*
1842      * Examine the PlatformClass field to determine the table type.
1843      * Either a client or server table. Only one.
1844      */
1845     TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer);
1846 
1847     switch (TcpaHeader->PlatformClass)
1848     {
1849     case ACPI_TCPA_CLIENT_TABLE:
1850 
1851         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient,
1852             &Subtable);
1853         break;
1854 
1855     case ACPI_TCPA_SERVER_TABLE:
1856 
1857         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer,
1858             &Subtable);
1859         break;
1860 
1861     default:
1862 
1863         AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
1864             TcpaHeader->PlatformClass);
1865         Status = AE_ERROR;
1866         break;
1867     }
1868 
1869     ParentTable = DtPeekSubtable ();
1870     DtInsertSubtable (ParentTable, Subtable);
1871     return (Status);
1872 }
1873 
1874 
1875 /******************************************************************************
1876  *
1877  * FUNCTION:    DtCompileTpm2Rev3
1878  *
1879  * PARAMETERS:  PFieldList          - Current field list pointer
1880  *
1881  * RETURN:      Status
1882  *
1883  * DESCRIPTION: Compile TPM2 revision 3
1884  *
1885  *****************************************************************************/
1886 static ACPI_STATUS
1887 DtCompileTpm2Rev3 (
1888     void                    **List)
1889 {
1890     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1891     DT_SUBTABLE             *Subtable;
1892     ACPI_TABLE_TPM23        *Tpm23Header;
1893     DT_SUBTABLE             *ParentTable;
1894     ACPI_STATUS             Status = AE_OK;
1895 
1896 
1897     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm23,
1898         &Subtable);
1899 
1900     ParentTable = DtPeekSubtable ();
1901     DtInsertSubtable (ParentTable, Subtable);
1902     Tpm23Header = ACPI_CAST_PTR (ACPI_TABLE_TPM23, ParentTable->Buffer);
1903 
1904     /* Subtable type depends on the StartMethod */
1905 
1906     switch (Tpm23Header->StartMethod)
1907     {
1908     case ACPI_TPM23_ACPI_START_METHOD:
1909 
1910         /* Subtable specific to to ARM_SMC */
1911 
1912         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm23a,
1913             &Subtable);
1914         if (ACPI_FAILURE (Status))
1915         {
1916             return (Status);
1917         }
1918 
1919         ParentTable = DtPeekSubtable ();
1920         DtInsertSubtable (ParentTable, Subtable);
1921         break;
1922 
1923     default:
1924         break;
1925     }
1926 
1927     return (Status);
1928 }
1929 
1930 
1931 /******************************************************************************
1932  *
1933  * FUNCTION:    DtCompileTpm2
1934  *
1935  * PARAMETERS:  PFieldList          - Current field list pointer
1936  *
1937  * RETURN:      Status
1938  *
1939  * DESCRIPTION: Compile TPM2.
1940  *
1941  *****************************************************************************/
1942 
1943 ACPI_STATUS
1944 DtCompileTpm2 (
1945     void                    **List)
1946 {
1947     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1948     DT_SUBTABLE             *Subtable;
1949     ACPI_TABLE_TPM2         *Tpm2Header;
1950     DT_SUBTABLE             *ParentTable;
1951     ACPI_STATUS             Status = AE_OK;
1952     ACPI_TABLE_HEADER       *Header;
1953 
1954 
1955     ParentTable = DtPeekSubtable ();
1956 
1957     Header = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
1958 
1959     if (Header->Revision == 3)
1960     {
1961         return (DtCompileTpm2Rev3 (List));
1962     }
1963 
1964     /* Compile the main table */
1965 
1966     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2,
1967         &Subtable);
1968     if (ACPI_FAILURE (Status))
1969     {
1970         return (Status);
1971     }
1972 
1973     ParentTable = DtPeekSubtable ();
1974     DtInsertSubtable (ParentTable, Subtable);
1975 
1976     Tpm2Header = ACPI_CAST_PTR (ACPI_TABLE_TPM2, ParentTable->Buffer);
1977 
1978     /* Method parameters */
1979     /* Optional: Log area minimum length */
1980     /* Optional: Log area start address */
1981     /* TBD: Optional fields above not fully implemented (not optional at this time) */
1982 
1983     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2a,
1984         &Subtable);
1985     if (ACPI_FAILURE (Status))
1986     {
1987         return (Status);
1988     }
1989 
1990     ParentTable = DtPeekSubtable ();
1991     DtInsertSubtable (ParentTable, Subtable);
1992 
1993 
1994     /* Subtable type depends on the StartMethod */
1995 
1996     switch (Tpm2Header->StartMethod)
1997     {
1998     case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
1999 
2000         /* Subtable specific to to ARM_SMC */
2001 
2002         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm211,
2003             &Subtable);
2004         if (ACPI_FAILURE (Status))
2005         {
2006             return (Status);
2007         }
2008 
2009         ParentTable = DtPeekSubtable ();
2010         DtInsertSubtable (ParentTable, Subtable);
2011         break;
2012 
2013     case ACPI_TPM2_START_METHOD:
2014     case ACPI_TPM2_MEMORY_MAPPED:
2015     case ACPI_TPM2_COMMAND_BUFFER:
2016     case ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD:
2017         break;
2018 
2019     case ACPI_TPM2_RESERVED1:
2020     case ACPI_TPM2_RESERVED3:
2021     case ACPI_TPM2_RESERVED4:
2022     case ACPI_TPM2_RESERVED5:
2023     case ACPI_TPM2_RESERVED9:
2024     case ACPI_TPM2_RESERVED10:
2025 
2026         AcpiOsPrintf ("\n**** Reserved TPM2 Start Method type 0x%X\n",
2027             Tpm2Header->StartMethod);
2028         Status = AE_ERROR;
2029         break;
2030 
2031     case ACPI_TPM2_NOT_ALLOWED:
2032     default:
2033 
2034         AcpiOsPrintf ("\n**** Unknown TPM2 Start Method type 0x%X\n",
2035             Tpm2Header->StartMethod);
2036         Status = AE_ERROR;
2037         break;
2038     }
2039 
2040     return (Status);
2041 }
2042 
2043 
2044 /******************************************************************************
2045  *
2046  * FUNCTION:    DtGetGenericTableInfo
2047  *
2048  * PARAMETERS:  Name                - Generic type name
2049  *
2050  * RETURN:      Info entry
2051  *
2052  * DESCRIPTION: Obtain table info for a generic name entry
2053  *
2054  *****************************************************************************/
2055 
2056 ACPI_DMTABLE_INFO *
2057 DtGetGenericTableInfo (
2058     char                    *Name)
2059 {
2060     ACPI_DMTABLE_INFO       *Info;
2061     UINT32                  i;
2062 
2063 
2064     if (!Name)
2065     {
2066         return (NULL);
2067     }
2068 
2069     /* Search info table for name match */
2070 
2071     for (i = 0; ; i++)
2072     {
2073         Info = AcpiDmTableInfoGeneric[i];
2074         if (Info->Opcode == ACPI_DMT_EXIT)
2075         {
2076             Info = NULL;
2077             break;
2078         }
2079 
2080         /* Use caseless compare for generic keywords */
2081 
2082         if (!AcpiUtStricmp (Name, Info->Name))
2083         {
2084             break;
2085         }
2086     }
2087 
2088     return (Info);
2089 }
2090 
2091 
2092 /******************************************************************************
2093  *
2094  * FUNCTION:    DtCompileUefi
2095  *
2096  * PARAMETERS:  List                - Current field list pointer
2097  *
2098  * RETURN:      Status
2099  *
2100  * DESCRIPTION: Compile UEFI.
2101  *
2102  *****************************************************************************/
2103 
2104 ACPI_STATUS
2105 DtCompileUefi (
2106     void                    **List)
2107 {
2108     ACPI_STATUS             Status;
2109     DT_SUBTABLE             *Subtable;
2110     DT_SUBTABLE             *ParentTable;
2111     DT_FIELD                **PFieldList = (DT_FIELD **) List;
2112     UINT16                  *DataOffset;
2113 
2114 
2115     /* Compile the predefined portion of the UEFI table */
2116 
2117     Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi,
2118         &Subtable);
2119     if (ACPI_FAILURE (Status))
2120     {
2121         return (Status);
2122     }
2123 
2124     DataOffset = (UINT16 *) (Subtable->Buffer + 16);
2125     *DataOffset = sizeof (ACPI_TABLE_UEFI);
2126 
2127     ParentTable = DtPeekSubtable ();
2128     DtInsertSubtable (ParentTable, Subtable);
2129 
2130     /*
2131      * Compile the "generic" portion of the UEFI table. This
2132      * part of the table is not predefined and any of the generic
2133      * operators may be used.
2134      */
2135     DtCompileGeneric ((void **) PFieldList, NULL, NULL);
2136     return (AE_OK);
2137 }
2138 
2139 
2140 /******************************************************************************
2141  *
2142  * FUNCTION:    DtCompileWdat
2143  *
2144  * PARAMETERS:  List                - Current field list pointer
2145  *
2146  * RETURN:      Status
2147  *
2148  * DESCRIPTION: Compile WDAT.
2149  *
2150  *****************************************************************************/
2151 
2152 ACPI_STATUS
2153 DtCompileWdat (
2154     void                    **List)
2155 {
2156     ACPI_STATUS             Status;
2157 
2158 
2159     Status = DtCompileTwoSubtables (List,
2160         AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0);
2161     return (Status);
2162 }
2163 
2164 
2165 /******************************************************************************
2166  *
2167  * FUNCTION:    DtCompileWpbt
2168  *
2169  * PARAMETERS:  List                - Current field list pointer
2170  *
2171  * RETURN:      Status
2172  *
2173  * DESCRIPTION: Compile WPBT.
2174  *
2175  *****************************************************************************/
2176 
2177 ACPI_STATUS
2178 DtCompileWpbt (
2179     void                    **List)
2180 {
2181     DT_FIELD                **PFieldList = (DT_FIELD **) List;
2182     DT_SUBTABLE             *Subtable;
2183     DT_SUBTABLE             *ParentTable;
2184     ACPI_TABLE_WPBT         *Table;
2185     ACPI_STATUS             Status;
2186     UINT16                  Length;
2187 
2188 
2189     /* Compile the main table */
2190 
2191     Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt,
2192         &Subtable);
2193     if (ACPI_FAILURE (Status))
2194     {
2195         return (Status);
2196     }
2197 
2198     ParentTable = DtPeekSubtable ();
2199     DtInsertSubtable (ParentTable, Subtable);
2200 
2201     /* Compile the argument list subtable */
2202 
2203     Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0,
2204         &Subtable);
2205     if (ACPI_FAILURE (Status))
2206     {
2207         return (Status);
2208     }
2209 
2210     /* Extract the length of the Arguments buffer, insert into main table */
2211 
2212     Length = (UINT16) Subtable->TotalLength;
2213     Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
2214     Table->ArgumentsLength = Length;
2215 
2216     ParentTable = DtPeekSubtable ();
2217     DtInsertSubtable (ParentTable, Subtable);
2218     return (AE_OK);
2219 }
2220 
2221 
2222 /******************************************************************************
2223  *
2224  * FUNCTION:    DtCompileXsdt
2225  *
2226  * PARAMETERS:  List                - Current field list pointer
2227  *
2228  * RETURN:      Status
2229  *
2230  * DESCRIPTION: Compile XSDT.
2231  *
2232  *****************************************************************************/
2233 
2234 ACPI_STATUS
2235 DtCompileXsdt (
2236     void                    **List)
2237 {
2238     DT_SUBTABLE             *Subtable;
2239     DT_SUBTABLE             *ParentTable;
2240     DT_FIELD                *FieldList = *(DT_FIELD **) List;
2241     UINT64                  Address;
2242 
2243 
2244     ParentTable = DtPeekSubtable ();
2245 
2246     while (FieldList)
2247     {
2248         DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO);
2249 
2250         DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable);
2251         DtInsertSubtable (ParentTable, Subtable);
2252         FieldList = FieldList->Next;
2253     }
2254 
2255     return (AE_OK);
2256 }
2257 
2258 
2259 /******************************************************************************
2260  *
2261  * FUNCTION:    DtCompileGeneric
2262  *
2263  * PARAMETERS:  List                - Current field list pointer
2264  *              Name                - Field name to end generic compiling
2265  *              Length              - Compiled table length to return
2266  *
2267  * RETURN:      Status
2268  *
2269  * DESCRIPTION: Compile generic unknown table.
2270  *
2271  *****************************************************************************/
2272 
2273 ACPI_STATUS
2274 DtCompileGeneric (
2275     void                    **List,
2276     char                    *Name,
2277     UINT32                  *Length)
2278 {
2279     ACPI_STATUS             Status;
2280     DT_SUBTABLE             *Subtable;
2281     DT_SUBTABLE             *ParentTable;
2282     DT_FIELD                **PFieldList = (DT_FIELD **) List;
2283     ACPI_DMTABLE_INFO       *Info;
2284 
2285 
2286     ParentTable = DtPeekSubtable ();
2287 
2288     /*
2289      * Compile the "generic" portion of the table. This
2290      * part of the table is not predefined and any of the generic
2291      * operators may be used.
2292      */
2293 
2294     /* Find any and all labels in the entire generic portion */
2295 
2296     DtDetectAllLabels (*PFieldList);
2297 
2298     /* Now we can actually compile the parse tree */
2299 
2300     if (Length && *Length)
2301     {
2302         *Length = 0;
2303     }
2304     while (*PFieldList)
2305     {
2306         if (Name && !strcmp ((*PFieldList)->Name, Name))
2307         {
2308             break;
2309         }
2310 
2311         Info = DtGetGenericTableInfo ((*PFieldList)->Name);
2312         if (!Info)
2313         {
2314             sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found",
2315                 (*PFieldList)->Name);
2316             DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2317                 (*PFieldList), AslGbl_MsgBuffer);
2318 
2319             *PFieldList = (*PFieldList)->Next;
2320             continue;
2321         }
2322 
2323         Status = DtCompileTable (PFieldList, Info,
2324             &Subtable);
2325         if (ACPI_SUCCESS (Status))
2326         {
2327             DtInsertSubtable (ParentTable, Subtable);
2328             if (Length)
2329             {
2330                 *Length += Subtable->Length;
2331             }
2332         }
2333         else
2334         {
2335             *PFieldList = (*PFieldList)->Next;
2336 
2337             if (Status == AE_NOT_FOUND)
2338             {
2339                 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found",
2340                     (*PFieldList)->Name);
2341                 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2342                     (*PFieldList), AslGbl_MsgBuffer);
2343             }
2344         }
2345     }
2346 
2347     return (AE_OK);
2348 }
2349