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