1 /******************************************************************************
2  *
3  * Module Name: dttable2.c - handling for specific ACPI tables
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 /* Compile all complex data tables, signatures starting with L-Z */
153 
154 #include "aslcompiler.h"
155 #include "dtcompiler.h"
156 
157 #define _COMPONENT          DT_COMPILER
158         ACPI_MODULE_NAME    ("dttable2")
159 
160 
161 /******************************************************************************
162  *
163  * FUNCTION:    DtCompileLpit
164  *
165  * PARAMETERS:  List                - Current field list pointer
166  *
167  * RETURN:      Status
168  *
169  * DESCRIPTION: Compile LPIT.
170  *
171  *****************************************************************************/
172 
173 ACPI_STATUS
174 DtCompileLpit (
175     void                    **List)
176 {
177     ACPI_STATUS             Status;
178     DT_SUBTABLE             *Subtable;
179     DT_SUBTABLE             *ParentTable;
180     DT_FIELD                **PFieldList = (DT_FIELD **) List;
181     DT_FIELD                *SubtableStart;
182     ACPI_DMTABLE_INFO       *InfoTable;
183     ACPI_LPIT_HEADER        *LpitHeader;
184 
185 
186     /* Note: Main table consists only of the standard ACPI table header */
187 
188     while (*PFieldList)
189     {
190         SubtableStart = *PFieldList;
191 
192         /* LPIT Subtable header */
193 
194         Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr,
195             &Subtable, TRUE);
196         if (ACPI_FAILURE (Status))
197         {
198             return (Status);
199         }
200 
201         ParentTable = DtPeekSubtable ();
202         DtInsertSubtable (ParentTable, Subtable);
203         DtPushSubtable (Subtable);
204 
205         LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer);
206 
207         switch (LpitHeader->Type)
208         {
209         case ACPI_LPIT_TYPE_NATIVE_CSTATE:
210 
211             InfoTable = AcpiDmTableInfoLpit0;
212             break;
213 
214         default:
215 
216             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT");
217             return (AE_ERROR);
218         }
219 
220         /* LPIT Subtable */
221 
222         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
223         if (ACPI_FAILURE (Status))
224         {
225             return (Status);
226         }
227 
228         ParentTable = DtPeekSubtable ();
229         DtInsertSubtable (ParentTable, Subtable);
230         DtPopSubtable ();
231     }
232 
233     return (AE_OK);
234 }
235 
236 
237 /******************************************************************************
238  *
239  * FUNCTION:    DtCompileMadt
240  *
241  * PARAMETERS:  List                - Current field list pointer
242  *
243  * RETURN:      Status
244  *
245  * DESCRIPTION: Compile MADT.
246  *
247  *****************************************************************************/
248 
249 ACPI_STATUS
250 DtCompileMadt (
251     void                    **List)
252 {
253     ACPI_STATUS             Status;
254     DT_SUBTABLE             *Subtable;
255     DT_SUBTABLE             *ParentTable;
256     DT_FIELD                **PFieldList = (DT_FIELD **) List;
257     DT_FIELD                *SubtableStart;
258     ACPI_SUBTABLE_HEADER    *MadtHeader;
259     ACPI_DMTABLE_INFO       *InfoTable;
260 
261 
262     Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt,
263         &Subtable, TRUE);
264     if (ACPI_FAILURE (Status))
265     {
266         return (Status);
267     }
268 
269     ParentTable = DtPeekSubtable ();
270     DtInsertSubtable (ParentTable, Subtable);
271 
272     while (*PFieldList)
273     {
274         SubtableStart = *PFieldList;
275         Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr,
276             &Subtable, TRUE);
277         if (ACPI_FAILURE (Status))
278         {
279             return (Status);
280         }
281 
282         ParentTable = DtPeekSubtable ();
283         DtInsertSubtable (ParentTable, Subtable);
284         DtPushSubtable (Subtable);
285 
286         MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
287 
288         switch (MadtHeader->Type)
289         {
290         case ACPI_MADT_TYPE_LOCAL_APIC:
291 
292             InfoTable = AcpiDmTableInfoMadt0;
293             break;
294 
295         case ACPI_MADT_TYPE_IO_APIC:
296 
297             InfoTable = AcpiDmTableInfoMadt1;
298             break;
299 
300         case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
301 
302             InfoTable = AcpiDmTableInfoMadt2;
303             break;
304 
305         case ACPI_MADT_TYPE_NMI_SOURCE:
306 
307             InfoTable = AcpiDmTableInfoMadt3;
308             break;
309 
310         case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
311 
312             InfoTable = AcpiDmTableInfoMadt4;
313             break;
314 
315         case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
316 
317             InfoTable = AcpiDmTableInfoMadt5;
318             break;
319 
320         case ACPI_MADT_TYPE_IO_SAPIC:
321 
322             InfoTable = AcpiDmTableInfoMadt6;
323             break;
324 
325         case ACPI_MADT_TYPE_LOCAL_SAPIC:
326 
327             InfoTable = AcpiDmTableInfoMadt7;
328             break;
329 
330         case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
331 
332             InfoTable = AcpiDmTableInfoMadt8;
333             break;
334 
335         case ACPI_MADT_TYPE_LOCAL_X2APIC:
336 
337             InfoTable = AcpiDmTableInfoMadt9;
338             break;
339 
340         case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
341 
342             InfoTable = AcpiDmTableInfoMadt10;
343             break;
344 
345         case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
346 
347             InfoTable = AcpiDmTableInfoMadt11;
348             break;
349 
350         case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
351 
352             InfoTable = AcpiDmTableInfoMadt12;
353             break;
354 
355         case ACPI_MADT_TYPE_GENERIC_MSI_FRAME:
356 
357             InfoTable = AcpiDmTableInfoMadt13;
358             break;
359 
360         case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR:
361 
362             InfoTable = AcpiDmTableInfoMadt14;
363             break;
364 
365         case ACPI_MADT_TYPE_GENERIC_TRANSLATOR:
366 
367             InfoTable = AcpiDmTableInfoMadt15;
368             break;
369 
370         default:
371 
372             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT");
373             return (AE_ERROR);
374         }
375 
376         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
377         if (ACPI_FAILURE (Status))
378         {
379             return (Status);
380         }
381 
382         ParentTable = DtPeekSubtable ();
383         DtInsertSubtable (ParentTable, Subtable);
384         DtPopSubtable ();
385     }
386 
387     return (AE_OK);
388 }
389 
390 
391 /******************************************************************************
392  *
393  * FUNCTION:    DtCompileMcfg
394  *
395  * PARAMETERS:  List                - Current field list pointer
396  *
397  * RETURN:      Status
398  *
399  * DESCRIPTION: Compile MCFG.
400  *
401  *****************************************************************************/
402 
403 ACPI_STATUS
404 DtCompileMcfg (
405     void                    **List)
406 {
407     ACPI_STATUS             Status;
408 
409 
410     Status = DtCompileTwoSubtables (List,
411         AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0);
412     return (Status);
413 }
414 
415 
416 /******************************************************************************
417  *
418  * FUNCTION:    DtCompileMpst
419  *
420  * PARAMETERS:  List                - Current field list pointer
421  *
422  * RETURN:      Status
423  *
424  * DESCRIPTION: Compile MPST.
425  *
426  *****************************************************************************/
427 
428 ACPI_STATUS
429 DtCompileMpst (
430     void                    **List)
431 {
432     ACPI_STATUS             Status;
433     DT_SUBTABLE             *Subtable;
434     DT_SUBTABLE             *ParentTable;
435     DT_FIELD                **PFieldList = (DT_FIELD **) List;
436     ACPI_MPST_CHANNEL       *MpstChannelInfo;
437     ACPI_MPST_POWER_NODE    *MpstPowerNode;
438     ACPI_MPST_DATA_HDR      *MpstDataHeader;
439     UINT16                  SubtableCount;
440     UINT32                  PowerStateCount;
441     UINT32                  ComponentCount;
442 
443 
444     /* Main table */
445 
446     Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE);
447     if (ACPI_FAILURE (Status))
448     {
449         return (Status);
450     }
451 
452     ParentTable = DtPeekSubtable ();
453     DtInsertSubtable (ParentTable, Subtable);
454     DtPushSubtable (Subtable);
455 
456     MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer);
457     SubtableCount = MpstChannelInfo->PowerNodeCount;
458 
459     while (*PFieldList && SubtableCount)
460     {
461         /* Subtable: Memory Power Node(s) */
462 
463         Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0,
464             &Subtable, TRUE);
465         if (ACPI_FAILURE (Status))
466         {
467             return (Status);
468         }
469 
470         ParentTable = DtPeekSubtable ();
471         DtInsertSubtable (ParentTable, Subtable);
472         DtPushSubtable (Subtable);
473 
474         MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer);
475         PowerStateCount = MpstPowerNode->NumPowerStates;
476         ComponentCount = MpstPowerNode->NumPhysicalComponents;
477 
478         ParentTable = DtPeekSubtable ();
479 
480         /* Sub-subtables - Memory Power State Structure(s) */
481 
482         while (*PFieldList && PowerStateCount)
483         {
484             Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A,
485                 &Subtable, TRUE);
486             if (ACPI_FAILURE (Status))
487             {
488                 return (Status);
489             }
490 
491             DtInsertSubtable (ParentTable, Subtable);
492             PowerStateCount--;
493         }
494 
495         /* Sub-subtables - Physical Component ID Structure(s) */
496 
497         while (*PFieldList && ComponentCount)
498         {
499             Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B,
500                 &Subtable, TRUE);
501             if (ACPI_FAILURE (Status))
502             {
503                 return (Status);
504             }
505 
506             DtInsertSubtable (ParentTable, Subtable);
507             ComponentCount--;
508         }
509 
510         SubtableCount--;
511         DtPopSubtable ();
512     }
513 
514     /* Subtable: Count of Memory Power State Characteristic structures */
515 
516     DtPopSubtable ();
517 
518     Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE);
519     if (ACPI_FAILURE (Status))
520     {
521         return (Status);
522     }
523 
524     ParentTable = DtPeekSubtable ();
525     DtInsertSubtable (ParentTable, Subtable);
526     DtPushSubtable (Subtable);
527 
528     MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer);
529     SubtableCount = MpstDataHeader->CharacteristicsCount;
530 
531     ParentTable = DtPeekSubtable ();
532 
533     /* Subtable: Memory Power State Characteristics structure(s) */
534 
535     while (*PFieldList && SubtableCount)
536     {
537         Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2,
538             &Subtable, TRUE);
539         if (ACPI_FAILURE (Status))
540         {
541             return (Status);
542         }
543 
544         DtInsertSubtable (ParentTable, Subtable);
545         SubtableCount--;
546     }
547 
548     DtPopSubtable ();
549     return (AE_OK);
550 }
551 
552 
553 /******************************************************************************
554  *
555  * FUNCTION:    DtCompileMsct
556  *
557  * PARAMETERS:  List                - Current field list pointer
558  *
559  * RETURN:      Status
560  *
561  * DESCRIPTION: Compile MSCT.
562  *
563  *****************************************************************************/
564 
565 ACPI_STATUS
566 DtCompileMsct (
567     void                    **List)
568 {
569     ACPI_STATUS             Status;
570 
571 
572     Status = DtCompileTwoSubtables (List,
573         AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0);
574     return (Status);
575 }
576 
577 
578 /******************************************************************************
579  *
580  * FUNCTION:    DtCompileMtmr
581  *
582  * PARAMETERS:  List                - Current field list pointer
583  *
584  * RETURN:      Status
585  *
586  * DESCRIPTION: Compile MTMR.
587  *
588  *****************************************************************************/
589 
590 ACPI_STATUS
591 DtCompileMtmr (
592     void                    **List)
593 {
594     ACPI_STATUS             Status;
595 
596 
597     Status = DtCompileTwoSubtables (List,
598         AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0);
599     return (Status);
600 }
601 
602 
603 /******************************************************************************
604  *
605  * FUNCTION:    DtCompileNfit
606  *
607  * PARAMETERS:  List                - Current field list pointer
608  *
609  * RETURN:      Status
610  *
611  * DESCRIPTION: Compile NFIT.
612  *
613  *****************************************************************************/
614 
615 ACPI_STATUS
616 DtCompileNfit (
617     void                    **List)
618 {
619     ACPI_STATUS             Status;
620     DT_SUBTABLE             *Subtable;
621     DT_SUBTABLE             *ParentTable;
622     DT_FIELD                **PFieldList = (DT_FIELD **) List;
623     DT_FIELD                *SubtableStart;
624     ACPI_NFIT_HEADER        *NfitHeader;
625     ACPI_DMTABLE_INFO       *InfoTable;
626     UINT32                  Count;
627     ACPI_NFIT_INTERLEAVE    *Interleave = NULL;
628     ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
629 
630 
631     /* Main table */
632 
633     Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit,
634         &Subtable, TRUE);
635     if (ACPI_FAILURE (Status))
636     {
637         return (Status);
638     }
639 
640     ParentTable = DtPeekSubtable ();
641     DtInsertSubtable (ParentTable, Subtable);
642     DtPushSubtable (Subtable);
643 
644     /* Subtables */
645 
646     while (*PFieldList)
647     {
648         SubtableStart = *PFieldList;
649         Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr,
650             &Subtable, TRUE);
651         if (ACPI_FAILURE (Status))
652         {
653             return (Status);
654         }
655 
656         ParentTable = DtPeekSubtable ();
657         DtInsertSubtable (ParentTable, Subtable);
658         DtPushSubtable (Subtable);
659 
660         NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
661 
662         switch (NfitHeader->Type)
663         {
664         case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
665 
666             InfoTable = AcpiDmTableInfoNfit0;
667             break;
668 
669         case ACPI_NFIT_TYPE_MEMORY_MAP:
670 
671             InfoTable = AcpiDmTableInfoNfit1;
672             break;
673 
674         case ACPI_NFIT_TYPE_INTERLEAVE:
675 
676             Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer);
677             InfoTable = AcpiDmTableInfoNfit2;
678             break;
679 
680         case ACPI_NFIT_TYPE_SMBIOS:
681 
682             InfoTable = AcpiDmTableInfoNfit3;
683             break;
684 
685         case ACPI_NFIT_TYPE_CONTROL_REGION:
686 
687             InfoTable = AcpiDmTableInfoNfit4;
688             break;
689 
690         case ACPI_NFIT_TYPE_DATA_REGION:
691 
692             InfoTable = AcpiDmTableInfoNfit5;
693             break;
694 
695         case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
696 
697             Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer);
698             InfoTable = AcpiDmTableInfoNfit6;
699             break;
700 
701         default:
702 
703             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT");
704             return (AE_ERROR);
705         }
706 
707         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
708         if (ACPI_FAILURE (Status))
709         {
710             return (Status);
711         }
712 
713         ParentTable = DtPeekSubtable ();
714         DtInsertSubtable (ParentTable, Subtable);
715         DtPopSubtable ();
716 
717         switch (NfitHeader->Type)
718         {
719         case ACPI_NFIT_TYPE_INTERLEAVE:
720 
721             Count = 0;
722             DtPushSubtable (Subtable);
723             while (*PFieldList)
724             {
725                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a,
726                     &Subtable, FALSE);
727                 if (ACPI_FAILURE (Status))
728                 {
729                     return (Status);
730                 }
731 
732                 if (!Subtable)
733                 {
734                     DtPopSubtable ();
735                     break;
736                 }
737 
738                 ParentTable = DtPeekSubtable ();
739                 DtInsertSubtable (ParentTable, Subtable);
740                 Count++;
741             }
742 
743             Interleave->LineCount = Count;
744             DtPopSubtable ();
745             break;
746 
747         case ACPI_NFIT_TYPE_SMBIOS:
748 
749             if (*PFieldList)
750             {
751                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a,
752                     &Subtable, TRUE);
753                 if (ACPI_FAILURE (Status))
754                 {
755                     return (Status);
756                 }
757 
758                 if (Subtable)
759                 {
760                     DtInsertSubtable (ParentTable, Subtable);
761                 }
762             }
763             break;
764 
765         case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
766 
767             Count = 0;
768             DtPushSubtable (Subtable);
769             while (*PFieldList)
770             {
771                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a,
772                     &Subtable, FALSE);
773                 if (ACPI_FAILURE (Status))
774                 {
775                     return (Status);
776                 }
777 
778                 if (!Subtable)
779                 {
780                     DtPopSubtable ();
781                     break;
782                 }
783 
784                 ParentTable = DtPeekSubtable ();
785                 DtInsertSubtable (ParentTable, Subtable);
786                 Count++;
787             }
788 
789             Hint->HintCount = (UINT16) Count;
790             DtPopSubtable ();
791             break;
792 
793         default:
794             break;
795         }
796     }
797 
798     return (AE_OK);
799 }
800 
801 
802 /******************************************************************************
803  *
804  * FUNCTION:    DtCompilePcct
805  *
806  * PARAMETERS:  List                - Current field list pointer
807  *
808  * RETURN:      Status
809  *
810  * DESCRIPTION: Compile PCCT.
811  *
812  *****************************************************************************/
813 
814 ACPI_STATUS
815 DtCompilePcct (
816     void                    **List)
817 {
818     ACPI_STATUS             Status;
819     DT_SUBTABLE             *Subtable;
820     DT_SUBTABLE             *ParentTable;
821     DT_FIELD                **PFieldList = (DT_FIELD **) List;
822     DT_FIELD                *SubtableStart;
823     ACPI_SUBTABLE_HEADER    *PcctHeader;
824     ACPI_DMTABLE_INFO       *InfoTable;
825 
826 
827     /* Main table */
828 
829     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct,
830         &Subtable, TRUE);
831     if (ACPI_FAILURE (Status))
832     {
833         return (Status);
834     }
835 
836     ParentTable = DtPeekSubtable ();
837     DtInsertSubtable (ParentTable, Subtable);
838 
839     /* Subtables */
840 
841     while (*PFieldList)
842     {
843         SubtableStart = *PFieldList;
844         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr,
845             &Subtable, TRUE);
846         if (ACPI_FAILURE (Status))
847         {
848             return (Status);
849         }
850 
851         ParentTable = DtPeekSubtable ();
852         DtInsertSubtable (ParentTable, Subtable);
853         DtPushSubtable (Subtable);
854 
855         PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
856 
857         switch (PcctHeader->Type)
858         {
859         case ACPI_PCCT_TYPE_GENERIC_SUBSPACE:
860 
861             InfoTable = AcpiDmTableInfoPcct0;
862             break;
863 
864         case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE:
865 
866             InfoTable = AcpiDmTableInfoPcct1;
867             break;
868 
869         case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2:
870 
871             InfoTable = AcpiDmTableInfoPcct2;
872             break;
873 
874         case ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE:
875 
876             InfoTable = AcpiDmTableInfoPcct3;
877             break;
878 
879         case ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE:
880 
881             InfoTable = AcpiDmTableInfoPcct4;
882             break;
883 
884         default:
885 
886             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT");
887             return (AE_ERROR);
888         }
889 
890         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
891         if (ACPI_FAILURE (Status))
892         {
893             return (Status);
894         }
895 
896         ParentTable = DtPeekSubtable ();
897         DtInsertSubtable (ParentTable, Subtable);
898         DtPopSubtable ();
899     }
900 
901     return (AE_OK);
902 }
903 
904 
905 /******************************************************************************
906  *
907  * FUNCTION:    DtCompilePmtt
908  *
909  * PARAMETERS:  List                - Current field list pointer
910  *
911  * RETURN:      Status
912  *
913  * DESCRIPTION: Compile PMTT.
914  *
915  *****************************************************************************/
916 
917 ACPI_STATUS
918 DtCompilePmtt (
919     void                    **List)
920 {
921     ACPI_STATUS             Status;
922     DT_SUBTABLE             *Subtable;
923     DT_SUBTABLE             *ParentTable;
924     DT_FIELD                **PFieldList = (DT_FIELD **) List;
925     DT_FIELD                *SubtableStart;
926     ACPI_PMTT_HEADER        *PmttHeader;
927     ACPI_PMTT_CONTROLLER    *PmttController;
928     UINT16                  DomainCount;
929     UINT8                   PrevType = ACPI_PMTT_TYPE_SOCKET;
930 
931 
932     /* Main table */
933 
934     Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE);
935     if (ACPI_FAILURE (Status))
936     {
937         return (Status);
938     }
939 
940     ParentTable = DtPeekSubtable ();
941     DtInsertSubtable (ParentTable, Subtable);
942     DtPushSubtable (Subtable);
943 
944     while (*PFieldList)
945     {
946         SubtableStart = *PFieldList;
947         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr,
948             &Subtable, TRUE);
949         if (ACPI_FAILURE (Status))
950         {
951             return (Status);
952         }
953 
954         PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer);
955         while (PrevType >= PmttHeader->Type)
956         {
957             DtPopSubtable ();
958 
959             if (PrevType == ACPI_PMTT_TYPE_SOCKET)
960             {
961                 break;
962             }
963 
964             PrevType--;
965         }
966 
967         PrevType = PmttHeader->Type;
968 
969         ParentTable = DtPeekSubtable ();
970         DtInsertSubtable (ParentTable, Subtable);
971         DtPushSubtable (Subtable);
972 
973         switch (PmttHeader->Type)
974         {
975         case ACPI_PMTT_TYPE_SOCKET:
976 
977             /* Subtable: Socket Structure */
978 
979             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0,
980                 &Subtable, TRUE);
981             if (ACPI_FAILURE (Status))
982             {
983                 return (Status);
984             }
985 
986             ParentTable = DtPeekSubtable ();
987             DtInsertSubtable (ParentTable, Subtable);
988             break;
989 
990         case ACPI_PMTT_TYPE_CONTROLLER:
991 
992             /* Subtable: Memory Controller Structure */
993 
994             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1,
995                 &Subtable, TRUE);
996             if (ACPI_FAILURE (Status))
997             {
998                 return (Status);
999             }
1000 
1001             ParentTable = DtPeekSubtable ();
1002             DtInsertSubtable (ParentTable, Subtable);
1003 
1004             PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER,
1005                 (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER)));
1006             DomainCount = PmttController->DomainCount;
1007 
1008             while (DomainCount)
1009             {
1010                 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a,
1011                     &Subtable, TRUE);
1012                 if (ACPI_FAILURE (Status))
1013                 {
1014                     return (Status);
1015                 }
1016 
1017                 DtInsertSubtable (ParentTable, Subtable);
1018                 DomainCount--;
1019             }
1020             break;
1021 
1022         case ACPI_PMTT_TYPE_DIMM:
1023 
1024             /* Subtable: Physical Component Structure */
1025 
1026             Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2,
1027                 &Subtable, TRUE);
1028             if (ACPI_FAILURE (Status))
1029             {
1030                 return (Status);
1031             }
1032 
1033             ParentTable = DtPeekSubtable ();
1034             DtInsertSubtable (ParentTable, Subtable);
1035             break;
1036 
1037         default:
1038 
1039             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT");
1040             return (AE_ERROR);
1041         }
1042     }
1043 
1044     return (Status);
1045 }
1046 
1047 
1048 /******************************************************************************
1049  *
1050  * FUNCTION:    DtCompilePptt
1051  *
1052  * PARAMETERS:  List                - Current field list pointer
1053  *
1054  * RETURN:      Status
1055  *
1056  * DESCRIPTION: Compile PPTT.
1057  *
1058  *****************************************************************************/
1059 
1060 ACPI_STATUS
1061 DtCompilePptt (
1062     void                    **List)
1063 {
1064     ACPI_STATUS             Status;
1065     ACPI_SUBTABLE_HEADER    *PpttHeader;
1066     ACPI_PPTT_PROCESSOR     *PpttProcessor = NULL;
1067     DT_SUBTABLE             *Subtable;
1068     DT_SUBTABLE             *ParentTable;
1069     ACPI_DMTABLE_INFO       *InfoTable;
1070     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1071     DT_FIELD                *SubtableStart;
1072 
1073 
1074     ParentTable = DtPeekSubtable ();
1075     while (*PFieldList)
1076     {
1077         SubtableStart = *PFieldList;
1078 
1079         /* Compile PPTT subtable header */
1080 
1081         Status = DtCompileTable (PFieldList, AcpiDmTableInfoPpttHdr,
1082             &Subtable, TRUE);
1083         if (ACPI_FAILURE (Status))
1084         {
1085             return (Status);
1086         }
1087         DtInsertSubtable (ParentTable, Subtable);
1088         PpttHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1089         PpttHeader->Length = (UINT8)(Subtable->Length);
1090 
1091         switch (PpttHeader->Type)
1092         {
1093         case ACPI_PPTT_TYPE_PROCESSOR:
1094 
1095             InfoTable = AcpiDmTableInfoPptt0;
1096             break;
1097 
1098         case ACPI_PPTT_TYPE_CACHE:
1099 
1100             InfoTable = AcpiDmTableInfoPptt1;
1101             break;
1102 
1103         case ACPI_PPTT_TYPE_ID:
1104 
1105             InfoTable = AcpiDmTableInfoPptt2;
1106             break;
1107 
1108         default:
1109 
1110             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PPTT");
1111             return (AE_ERROR);
1112         }
1113 
1114         /* Compile PPTT subtable body */
1115 
1116         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1117         if (ACPI_FAILURE (Status))
1118         {
1119             return (Status);
1120         }
1121         DtInsertSubtable (ParentTable, Subtable);
1122         PpttHeader->Length += (UINT8)(Subtable->Length);
1123 
1124         /* Compile PPTT subtable additionals */
1125 
1126         switch (PpttHeader->Type)
1127         {
1128         case ACPI_PPTT_TYPE_PROCESSOR:
1129 
1130             PpttProcessor = ACPI_SUB_PTR (ACPI_PPTT_PROCESSOR,
1131                 Subtable->Buffer, sizeof (ACPI_SUBTABLE_HEADER));
1132             if (PpttProcessor)
1133             {
1134                 /* Compile initiator proximity domain list */
1135 
1136                 PpttProcessor->NumberOfPrivResources = 0;
1137                 while (*PFieldList)
1138                 {
1139                     Status = DtCompileTable (PFieldList,
1140                         AcpiDmTableInfoPptt0a, &Subtable, TRUE);
1141                     if (ACPI_FAILURE (Status))
1142                     {
1143                         return (Status);
1144                     }
1145                     if (!Subtable)
1146                     {
1147                         break;
1148                     }
1149 
1150                     DtInsertSubtable (ParentTable, Subtable);
1151                     PpttHeader->Length += (UINT8)(Subtable->Length);
1152                     PpttProcessor->NumberOfPrivResources++;
1153                 }
1154             }
1155             break;
1156 
1157         default:
1158 
1159             break;
1160         }
1161     }
1162 
1163     return (AE_OK);
1164 }
1165 
1166 
1167 /******************************************************************************
1168  *
1169  * FUNCTION:    DtCompileRsdt
1170  *
1171  * PARAMETERS:  List                - Current field list pointer
1172  *
1173  * RETURN:      Status
1174  *
1175  * DESCRIPTION: Compile RSDT.
1176  *
1177  *****************************************************************************/
1178 
1179 ACPI_STATUS
1180 DtCompileRsdt (
1181     void                    **List)
1182 {
1183     DT_SUBTABLE             *Subtable;
1184     DT_SUBTABLE             *ParentTable;
1185     DT_FIELD                *FieldList = *(DT_FIELD **) List;
1186     UINT32                  Address;
1187 
1188 
1189     ParentTable = DtPeekSubtable ();
1190 
1191     while (FieldList)
1192     {
1193         DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO);
1194 
1195         DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable);
1196         DtInsertSubtable (ParentTable, Subtable);
1197         FieldList = FieldList->Next;
1198     }
1199 
1200     return (AE_OK);
1201 }
1202 
1203 
1204 /******************************************************************************
1205  *
1206  * FUNCTION:    DtCompileS3pt
1207  *
1208  * PARAMETERS:  PFieldList          - Current field list pointer
1209  *
1210  * RETURN:      Status
1211  *
1212  * DESCRIPTION: Compile S3PT (Pointed to by FPDT)
1213  *
1214  *****************************************************************************/
1215 
1216 ACPI_STATUS
1217 DtCompileS3pt (
1218     DT_FIELD                **PFieldList)
1219 {
1220     ACPI_STATUS             Status;
1221     ACPI_FPDT_HEADER        *S3ptHeader;
1222     DT_SUBTABLE             *Subtable;
1223     DT_SUBTABLE             *ParentTable;
1224     ACPI_DMTABLE_INFO       *InfoTable;
1225     DT_FIELD                *SubtableStart;
1226 
1227 
1228     Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt,
1229         &Gbl_RootTable, TRUE);
1230     if (ACPI_FAILURE (Status))
1231     {
1232         return (Status);
1233     }
1234 
1235     DtPushSubtable (Gbl_RootTable);
1236 
1237     while (*PFieldList)
1238     {
1239         SubtableStart = *PFieldList;
1240         Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr,
1241             &Subtable, TRUE);
1242         if (ACPI_FAILURE (Status))
1243         {
1244             return (Status);
1245         }
1246 
1247         ParentTable = DtPeekSubtable ();
1248         DtInsertSubtable (ParentTable, Subtable);
1249         DtPushSubtable (Subtable);
1250 
1251         S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
1252 
1253         switch (S3ptHeader->Type)
1254         {
1255         case ACPI_S3PT_TYPE_RESUME:
1256 
1257             InfoTable = AcpiDmTableInfoS3pt0;
1258             break;
1259 
1260         case ACPI_S3PT_TYPE_SUSPEND:
1261 
1262             InfoTable = AcpiDmTableInfoS3pt1;
1263             break;
1264 
1265         default:
1266 
1267             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT");
1268             return (AE_ERROR);
1269         }
1270 
1271         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1272         if (ACPI_FAILURE (Status))
1273         {
1274             return (Status);
1275         }
1276 
1277         ParentTable = DtPeekSubtable ();
1278         DtInsertSubtable (ParentTable, Subtable);
1279         DtPopSubtable ();
1280     }
1281 
1282     return (AE_OK);
1283 }
1284 
1285 
1286 /******************************************************************************
1287  *
1288  * FUNCTION:    DtCompileSlic
1289  *
1290  * PARAMETERS:  List                - Current field list pointer
1291  *
1292  * RETURN:      Status
1293  *
1294  * DESCRIPTION: Compile SLIC.
1295  *
1296  *****************************************************************************/
1297 
1298 ACPI_STATUS
1299 DtCompileSlic (
1300     void                    **List)
1301 {
1302     ACPI_STATUS             Status;
1303     DT_SUBTABLE             *Subtable;
1304     DT_SUBTABLE             *ParentTable;
1305     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1306 
1307 
1308     while (*PFieldList)
1309     {
1310         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic,
1311             &Subtable, TRUE);
1312         if (ACPI_FAILURE (Status))
1313         {
1314             return (Status);
1315         }
1316 
1317         ParentTable = DtPeekSubtable ();
1318         DtInsertSubtable (ParentTable, Subtable);
1319         DtPushSubtable (Subtable);
1320         DtPopSubtable ();
1321     }
1322 
1323     return (AE_OK);
1324 }
1325 
1326 
1327 /******************************************************************************
1328  *
1329  * FUNCTION:    DtCompileSlit
1330  *
1331  * PARAMETERS:  List                - Current field list pointer
1332  *
1333  * RETURN:      Status
1334  *
1335  * DESCRIPTION: Compile SLIT.
1336  *
1337  *****************************************************************************/
1338 
1339 ACPI_STATUS
1340 DtCompileSlit (
1341     void                    **List)
1342 {
1343     ACPI_STATUS             Status;
1344     DT_SUBTABLE             *Subtable;
1345     DT_SUBTABLE             *ParentTable;
1346     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1347     DT_FIELD                *FieldList;
1348     UINT32                  Localities;
1349     UINT8                   *LocalityBuffer;
1350 
1351 
1352     Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
1353         &Subtable, TRUE);
1354     if (ACPI_FAILURE (Status))
1355     {
1356         return (Status);
1357     }
1358 
1359     ParentTable = DtPeekSubtable ();
1360     DtInsertSubtable (ParentTable, Subtable);
1361 
1362     Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
1363     LocalityBuffer = UtLocalCalloc (Localities);
1364 
1365     /* Compile each locality buffer */
1366 
1367     FieldList = *PFieldList;
1368     while (FieldList)
1369     {
1370         DtCompileBuffer (LocalityBuffer,
1371             FieldList->Value, FieldList, Localities);
1372 
1373         DtCreateSubtable (LocalityBuffer, Localities, &Subtable);
1374         DtInsertSubtable (ParentTable, Subtable);
1375         FieldList = FieldList->Next;
1376     }
1377 
1378     ACPI_FREE (LocalityBuffer);
1379     return (AE_OK);
1380 }
1381 
1382 
1383 /******************************************************************************
1384  *
1385  * FUNCTION:    DtCompileSrat
1386  *
1387  * PARAMETERS:  List                - Current field list pointer
1388  *
1389  * RETURN:      Status
1390  *
1391  * DESCRIPTION: Compile SRAT.
1392  *
1393  *****************************************************************************/
1394 
1395 ACPI_STATUS
1396 DtCompileSrat (
1397     void                    **List)
1398 {
1399     ACPI_STATUS             Status;
1400     DT_SUBTABLE             *Subtable;
1401     DT_SUBTABLE             *ParentTable;
1402     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1403     DT_FIELD                *SubtableStart;
1404     ACPI_SUBTABLE_HEADER    *SratHeader;
1405     ACPI_DMTABLE_INFO       *InfoTable;
1406 
1407 
1408     Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat,
1409         &Subtable, TRUE);
1410     if (ACPI_FAILURE (Status))
1411     {
1412         return (Status);
1413     }
1414 
1415     ParentTable = DtPeekSubtable ();
1416     DtInsertSubtable (ParentTable, Subtable);
1417 
1418     while (*PFieldList)
1419     {
1420         SubtableStart = *PFieldList;
1421         Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr,
1422             &Subtable, TRUE);
1423         if (ACPI_FAILURE (Status))
1424         {
1425             return (Status);
1426         }
1427 
1428         ParentTable = DtPeekSubtable ();
1429         DtInsertSubtable (ParentTable, Subtable);
1430         DtPushSubtable (Subtable);
1431 
1432         SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1433 
1434         switch (SratHeader->Type)
1435         {
1436         case ACPI_SRAT_TYPE_CPU_AFFINITY:
1437 
1438             InfoTable = AcpiDmTableInfoSrat0;
1439             break;
1440 
1441         case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
1442 
1443             InfoTable = AcpiDmTableInfoSrat1;
1444             break;
1445 
1446         case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
1447 
1448             InfoTable = AcpiDmTableInfoSrat2;
1449             break;
1450 
1451         case ACPI_SRAT_TYPE_GICC_AFFINITY:
1452 
1453             InfoTable = AcpiDmTableInfoSrat3;
1454             break;
1455 
1456         case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
1457 
1458             InfoTable = AcpiDmTableInfoSrat4;
1459             break;
1460 
1461         default:
1462 
1463             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT");
1464             return (AE_ERROR);
1465         }
1466 
1467         Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1468         if (ACPI_FAILURE (Status))
1469         {
1470             return (Status);
1471         }
1472 
1473         ParentTable = DtPeekSubtable ();
1474         DtInsertSubtable (ParentTable, Subtable);
1475         DtPopSubtable ();
1476     }
1477 
1478     return (AE_OK);
1479 }
1480 
1481 
1482 /******************************************************************************
1483  *
1484  * FUNCTION:    DtCompileStao
1485  *
1486  * PARAMETERS:  PFieldList          - Current field list pointer
1487  *
1488  * RETURN:      Status
1489  *
1490  * DESCRIPTION: Compile STAO.
1491  *
1492  *****************************************************************************/
1493 
1494 ACPI_STATUS
1495 DtCompileStao (
1496     void                    **List)
1497 {
1498     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1499     DT_SUBTABLE             *Subtable;
1500     DT_SUBTABLE             *ParentTable;
1501     ACPI_STATUS             Status;
1502 
1503 
1504     /* Compile the main table */
1505 
1506     Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao,
1507         &Subtable, TRUE);
1508     if (ACPI_FAILURE (Status))
1509     {
1510         return (Status);
1511     }
1512 
1513     ParentTable = DtPeekSubtable ();
1514     DtInsertSubtable (ParentTable, Subtable);
1515 
1516     /* Compile each ASCII namestring as a subtable */
1517 
1518     while (*PFieldList)
1519     {
1520         Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr,
1521             &Subtable, TRUE);
1522         if (ACPI_FAILURE (Status))
1523         {
1524             return (Status);
1525         }
1526 
1527         ParentTable = DtPeekSubtable ();
1528         DtInsertSubtable (ParentTable, Subtable);
1529     }
1530 
1531     return (AE_OK);
1532 }
1533 
1534 
1535 /******************************************************************************
1536  *
1537  * FUNCTION:    DtCompileTcpa
1538  *
1539  * PARAMETERS:  PFieldList          - Current field list pointer
1540  *
1541  * RETURN:      Status
1542  *
1543  * DESCRIPTION: Compile TCPA.
1544  *
1545  *****************************************************************************/
1546 
1547 ACPI_STATUS
1548 DtCompileTcpa (
1549     void                    **List)
1550 {
1551     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1552     DT_SUBTABLE             *Subtable;
1553     ACPI_TABLE_TCPA_HDR     *TcpaHeader;
1554     DT_SUBTABLE             *ParentTable;
1555     ACPI_STATUS             Status;
1556 
1557 
1558     /* Compile the main table */
1559 
1560     Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr,
1561         &Subtable, TRUE);
1562     if (ACPI_FAILURE (Status))
1563     {
1564         return (Status);
1565     }
1566 
1567     ParentTable = DtPeekSubtable ();
1568     DtInsertSubtable (ParentTable, Subtable);
1569 
1570     /*
1571      * Examine the PlatformClass field to determine the table type.
1572      * Either a client or server table. Only one.
1573      */
1574     TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer);
1575 
1576     switch (TcpaHeader->PlatformClass)
1577     {
1578     case ACPI_TCPA_CLIENT_TABLE:
1579 
1580         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient,
1581             &Subtable, TRUE);
1582         break;
1583 
1584     case ACPI_TCPA_SERVER_TABLE:
1585 
1586         Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer,
1587             &Subtable, TRUE);
1588         break;
1589 
1590     default:
1591 
1592         AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
1593             TcpaHeader->PlatformClass);
1594         Status = AE_ERROR;
1595         break;
1596     }
1597 
1598     ParentTable = DtPeekSubtable ();
1599     DtInsertSubtable (ParentTable, Subtable);
1600     return (Status);
1601 }
1602 
1603 
1604 /******************************************************************************
1605  *
1606  * FUNCTION:    DtGetGenericTableInfo
1607  *
1608  * PARAMETERS:  Name                - Generic type name
1609  *
1610  * RETURN:      Info entry
1611  *
1612  * DESCRIPTION: Obtain table info for a generic name entry
1613  *
1614  *****************************************************************************/
1615 
1616 ACPI_DMTABLE_INFO *
1617 DtGetGenericTableInfo (
1618     char                    *Name)
1619 {
1620     ACPI_DMTABLE_INFO       *Info;
1621     UINT32                  i;
1622 
1623 
1624     if (!Name)
1625     {
1626         return (NULL);
1627     }
1628 
1629     /* Search info table for name match */
1630 
1631     for (i = 0; ; i++)
1632     {
1633         Info = AcpiDmTableInfoGeneric[i];
1634         if (Info->Opcode == ACPI_DMT_EXIT)
1635         {
1636             Info = NULL;
1637             break;
1638         }
1639 
1640         /* Use caseless compare for generic keywords */
1641 
1642         if (!AcpiUtStricmp (Name, Info->Name))
1643         {
1644             break;
1645         }
1646     }
1647 
1648     return (Info);
1649 }
1650 
1651 
1652 /******************************************************************************
1653  *
1654  * FUNCTION:    DtCompileUefi
1655  *
1656  * PARAMETERS:  List                - Current field list pointer
1657  *
1658  * RETURN:      Status
1659  *
1660  * DESCRIPTION: Compile UEFI.
1661  *
1662  *****************************************************************************/
1663 
1664 ACPI_STATUS
1665 DtCompileUefi (
1666     void                    **List)
1667 {
1668     ACPI_STATUS             Status;
1669     DT_SUBTABLE             *Subtable;
1670     DT_SUBTABLE             *ParentTable;
1671     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1672     UINT16                  *DataOffset;
1673 
1674 
1675     /* Compile the predefined portion of the UEFI table */
1676 
1677     Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi,
1678         &Subtable, TRUE);
1679     if (ACPI_FAILURE (Status))
1680     {
1681         return (Status);
1682     }
1683 
1684     DataOffset = (UINT16 *) (Subtable->Buffer + 16);
1685     *DataOffset = sizeof (ACPI_TABLE_UEFI);
1686 
1687     ParentTable = DtPeekSubtable ();
1688     DtInsertSubtable (ParentTable, Subtable);
1689 
1690     /*
1691      * Compile the "generic" portion of the UEFI table. This
1692      * part of the table is not predefined and any of the generic
1693      * operators may be used.
1694      */
1695     DtCompileGeneric ((void **) PFieldList, NULL, NULL);
1696     return (AE_OK);
1697 }
1698 
1699 
1700 /******************************************************************************
1701  *
1702  * FUNCTION:    DtCompileVrtc
1703  *
1704  * PARAMETERS:  List                - Current field list pointer
1705  *
1706  * RETURN:      Status
1707  *
1708  * DESCRIPTION: Compile VRTC.
1709  *
1710  *****************************************************************************/
1711 
1712 ACPI_STATUS
1713 DtCompileVrtc (
1714     void                    **List)
1715 {
1716     ACPI_STATUS             Status;
1717 
1718 
1719     Status = DtCompileTwoSubtables (List,
1720         AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0);
1721     return (Status);
1722 }
1723 
1724 
1725 /******************************************************************************
1726  *
1727  * FUNCTION:    DtCompileWdat
1728  *
1729  * PARAMETERS:  List                - Current field list pointer
1730  *
1731  * RETURN:      Status
1732  *
1733  * DESCRIPTION: Compile WDAT.
1734  *
1735  *****************************************************************************/
1736 
1737 ACPI_STATUS
1738 DtCompileWdat (
1739     void                    **List)
1740 {
1741     ACPI_STATUS             Status;
1742 
1743 
1744     Status = DtCompileTwoSubtables (List,
1745         AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0);
1746     return (Status);
1747 }
1748 
1749 
1750 /******************************************************************************
1751  *
1752  * FUNCTION:    DtCompileWpbt
1753  *
1754  * PARAMETERS:  List                - Current field list pointer
1755  *
1756  * RETURN:      Status
1757  *
1758  * DESCRIPTION: Compile WPBT.
1759  *
1760  *****************************************************************************/
1761 
1762 ACPI_STATUS
1763 DtCompileWpbt (
1764     void                    **List)
1765 {
1766     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1767     DT_SUBTABLE             *Subtable;
1768     DT_SUBTABLE             *ParentTable;
1769     ACPI_TABLE_WPBT         *Table;
1770     ACPI_STATUS             Status;
1771     UINT16                  Length;
1772 
1773 
1774     /* Compile the main table */
1775 
1776     Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt,
1777         &Subtable, TRUE);
1778     if (ACPI_FAILURE (Status))
1779     {
1780         return (Status);
1781     }
1782 
1783     ParentTable = DtPeekSubtable ();
1784     DtInsertSubtable (ParentTable, Subtable);
1785 
1786     /* Compile the argument list subtable */
1787 
1788     Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0,
1789         &Subtable, TRUE);
1790     if (ACPI_FAILURE (Status))
1791     {
1792         return (Status);
1793     }
1794 
1795     /* Extract the length of the Arguments buffer, insert into main table */
1796 
1797     Length = (UINT16) Subtable->TotalLength;
1798     Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
1799     Table->ArgumentsLength = Length;
1800 
1801     ParentTable = DtPeekSubtable ();
1802     DtInsertSubtable (ParentTable, Subtable);
1803     return (AE_OK);
1804 }
1805 
1806 
1807 /******************************************************************************
1808  *
1809  * FUNCTION:    DtCompileXsdt
1810  *
1811  * PARAMETERS:  List                - Current field list pointer
1812  *
1813  * RETURN:      Status
1814  *
1815  * DESCRIPTION: Compile XSDT.
1816  *
1817  *****************************************************************************/
1818 
1819 ACPI_STATUS
1820 DtCompileXsdt (
1821     void                    **List)
1822 {
1823     DT_SUBTABLE             *Subtable;
1824     DT_SUBTABLE             *ParentTable;
1825     DT_FIELD                *FieldList = *(DT_FIELD **) List;
1826     UINT64                  Address;
1827 
1828 
1829     ParentTable = DtPeekSubtable ();
1830 
1831     while (FieldList)
1832     {
1833         DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO);
1834 
1835         DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable);
1836         DtInsertSubtable (ParentTable, Subtable);
1837         FieldList = FieldList->Next;
1838     }
1839 
1840     return (AE_OK);
1841 }
1842 
1843 
1844 /******************************************************************************
1845  *
1846  * FUNCTION:    DtCompileGeneric
1847  *
1848  * PARAMETERS:  List                - Current field list pointer
1849  *              Name                - Field name to end generic compiling
1850  *              Length              - Compiled table length to return
1851  *
1852  * RETURN:      Status
1853  *
1854  * DESCRIPTION: Compile generic unknown table.
1855  *
1856  *****************************************************************************/
1857 
1858 ACPI_STATUS
1859 DtCompileGeneric (
1860     void                    **List,
1861     char                    *Name,
1862     UINT32                  *Length)
1863 {
1864     ACPI_STATUS             Status;
1865     DT_SUBTABLE             *Subtable;
1866     DT_SUBTABLE             *ParentTable;
1867     DT_FIELD                **PFieldList = (DT_FIELD **) List;
1868     ACPI_DMTABLE_INFO       *Info;
1869 
1870 
1871     ParentTable = DtPeekSubtable ();
1872 
1873     /*
1874      * Compile the "generic" portion of the table. This
1875      * part of the table is not predefined and any of the generic
1876      * operators may be used.
1877      */
1878 
1879     /* Find any and all labels in the entire generic portion */
1880 
1881     DtDetectAllLabels (*PFieldList);
1882 
1883     /* Now we can actually compile the parse tree */
1884 
1885     if (Length && *Length)
1886     {
1887         *Length = 0;
1888     }
1889     while (*PFieldList)
1890     {
1891         if (Name && !strcmp ((*PFieldList)->Name, Name))
1892         {
1893             break;
1894         }
1895 
1896         Info = DtGetGenericTableInfo ((*PFieldList)->Name);
1897         if (!Info)
1898         {
1899             sprintf (MsgBuffer, "Generic data type \"%s\" not found",
1900                 (*PFieldList)->Name);
1901             DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
1902                 (*PFieldList), MsgBuffer);
1903 
1904             *PFieldList = (*PFieldList)->Next;
1905             continue;
1906         }
1907 
1908         Status = DtCompileTable (PFieldList, Info,
1909             &Subtable, TRUE);
1910         if (ACPI_SUCCESS (Status))
1911         {
1912             DtInsertSubtable (ParentTable, Subtable);
1913             if (Length)
1914             {
1915                 *Length += Subtable->Length;
1916             }
1917         }
1918         else
1919         {
1920             *PFieldList = (*PFieldList)->Next;
1921 
1922             if (Status == AE_NOT_FOUND)
1923             {
1924                 sprintf (MsgBuffer, "Generic data type \"%s\" not found",
1925                     (*PFieldList)->Name);
1926                 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
1927                     (*PFieldList), MsgBuffer);
1928             }
1929         }
1930     }
1931 
1932     return (AE_OK);
1933 }
1934