Sync ACPICA with Intel's version 20180927:
[dragonfly.git] / sys / contrib / dev / acpica / source / compiler / dttable2.c
blob3f97037763f3f267c73f097a7cda26ea736f7e89
1 /******************************************************************************
3 * Module Name: dttable2.c - handling for specific ACPI tables
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
14 * 2. License
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.
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
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;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
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.
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.
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.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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.
80 * 4. Disclaimer and Export Compliance
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.
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.
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.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
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.
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.
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.
150 *****************************************************************************/
152 /* Compile all complex data tables, signatures starting with L-Z */
154 #include "aslcompiler.h"
156 #define _COMPONENT DT_COMPILER
157 ACPI_MODULE_NAME ("dttable2")
160 /******************************************************************************
162 * FUNCTION: DtCompileLpit
164 * PARAMETERS: List - Current field list pointer
166 * RETURN: Status
168 * DESCRIPTION: Compile LPIT.
170 *****************************************************************************/
172 ACPI_STATUS
173 DtCompileLpit (
174 void **List)
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;
185 /* Note: Main table consists only of the standard ACPI table header */
187 while (*PFieldList)
189 SubtableStart = *PFieldList;
191 /* LPIT Subtable header */
193 Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr,
194 &Subtable);
195 if (ACPI_FAILURE (Status))
197 return (Status);
200 ParentTable = DtPeekSubtable ();
201 DtInsertSubtable (ParentTable, Subtable);
202 DtPushSubtable (Subtable);
204 LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer);
206 switch (LpitHeader->Type)
208 case ACPI_LPIT_TYPE_NATIVE_CSTATE:
210 InfoTable = AcpiDmTableInfoLpit0;
211 break;
213 default:
215 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT");
216 return (AE_ERROR);
219 /* LPIT Subtable */
221 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
222 if (ACPI_FAILURE (Status))
224 return (Status);
227 ParentTable = DtPeekSubtable ();
228 DtInsertSubtable (ParentTable, Subtable);
229 DtPopSubtable ();
232 return (AE_OK);
236 /******************************************************************************
238 * FUNCTION: DtCompileMadt
240 * PARAMETERS: List - Current field list pointer
242 * RETURN: Status
244 * DESCRIPTION: Compile MADT.
246 *****************************************************************************/
248 ACPI_STATUS
249 DtCompileMadt (
250 void **List)
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;
261 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt,
262 &Subtable);
263 if (ACPI_FAILURE (Status))
265 return (Status);
268 ParentTable = DtPeekSubtable ();
269 DtInsertSubtable (ParentTable, Subtable);
271 while (*PFieldList)
273 SubtableStart = *PFieldList;
274 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr,
275 &Subtable);
276 if (ACPI_FAILURE (Status))
278 return (Status);
281 ParentTable = DtPeekSubtable ();
282 DtInsertSubtable (ParentTable, Subtable);
283 DtPushSubtable (Subtable);
285 MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
287 switch (MadtHeader->Type)
289 case ACPI_MADT_TYPE_LOCAL_APIC:
291 InfoTable = AcpiDmTableInfoMadt0;
292 break;
294 case ACPI_MADT_TYPE_IO_APIC:
296 InfoTable = AcpiDmTableInfoMadt1;
297 break;
299 case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
301 InfoTable = AcpiDmTableInfoMadt2;
302 break;
304 case ACPI_MADT_TYPE_NMI_SOURCE:
306 InfoTable = AcpiDmTableInfoMadt3;
307 break;
309 case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
311 InfoTable = AcpiDmTableInfoMadt4;
312 break;
314 case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
316 InfoTable = AcpiDmTableInfoMadt5;
317 break;
319 case ACPI_MADT_TYPE_IO_SAPIC:
321 InfoTable = AcpiDmTableInfoMadt6;
322 break;
324 case ACPI_MADT_TYPE_LOCAL_SAPIC:
326 InfoTable = AcpiDmTableInfoMadt7;
327 break;
329 case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
331 InfoTable = AcpiDmTableInfoMadt8;
332 break;
334 case ACPI_MADT_TYPE_LOCAL_X2APIC:
336 InfoTable = AcpiDmTableInfoMadt9;
337 break;
339 case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
341 InfoTable = AcpiDmTableInfoMadt10;
342 break;
344 case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
346 InfoTable = AcpiDmTableInfoMadt11;
347 break;
349 case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
351 InfoTable = AcpiDmTableInfoMadt12;
352 break;
354 case ACPI_MADT_TYPE_GENERIC_MSI_FRAME:
356 InfoTable = AcpiDmTableInfoMadt13;
357 break;
359 case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR:
361 InfoTable = AcpiDmTableInfoMadt14;
362 break;
364 case ACPI_MADT_TYPE_GENERIC_TRANSLATOR:
366 InfoTable = AcpiDmTableInfoMadt15;
367 break;
369 default:
371 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT");
372 return (AE_ERROR);
375 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
376 if (ACPI_FAILURE (Status))
378 return (Status);
381 ParentTable = DtPeekSubtable ();
382 DtInsertSubtable (ParentTable, Subtable);
383 DtPopSubtable ();
386 return (AE_OK);
390 /******************************************************************************
392 * FUNCTION: DtCompileMcfg
394 * PARAMETERS: List - Current field list pointer
396 * RETURN: Status
398 * DESCRIPTION: Compile MCFG.
400 *****************************************************************************/
402 ACPI_STATUS
403 DtCompileMcfg (
404 void **List)
406 ACPI_STATUS Status;
409 Status = DtCompileTwoSubtables (List,
410 AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0);
411 return (Status);
415 /******************************************************************************
417 * FUNCTION: DtCompileMpst
419 * PARAMETERS: List - Current field list pointer
421 * RETURN: Status
423 * DESCRIPTION: Compile MPST.
425 *****************************************************************************/
427 ACPI_STATUS
428 DtCompileMpst (
429 void **List)
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;
443 /* Main table */
445 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable);
446 if (ACPI_FAILURE (Status))
448 return (Status);
451 ParentTable = DtPeekSubtable ();
452 DtInsertSubtable (ParentTable, Subtable);
453 DtPushSubtable (Subtable);
455 MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer);
456 SubtableCount = MpstChannelInfo->PowerNodeCount;
458 while (*PFieldList && SubtableCount)
460 /* Subtable: Memory Power Node(s) */
462 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0,
463 &Subtable);
464 if (ACPI_FAILURE (Status))
466 return (Status);
469 ParentTable = DtPeekSubtable ();
470 DtInsertSubtable (ParentTable, Subtable);
471 DtPushSubtable (Subtable);
473 MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer);
474 PowerStateCount = MpstPowerNode->NumPowerStates;
475 ComponentCount = MpstPowerNode->NumPhysicalComponents;
477 ParentTable = DtPeekSubtable ();
479 /* Sub-subtables - Memory Power State Structure(s) */
481 while (*PFieldList && PowerStateCount)
483 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A,
484 &Subtable);
485 if (ACPI_FAILURE (Status))
487 return (Status);
490 DtInsertSubtable (ParentTable, Subtable);
491 PowerStateCount--;
494 /* Sub-subtables - Physical Component ID Structure(s) */
496 while (*PFieldList && ComponentCount)
498 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B,
499 &Subtable);
500 if (ACPI_FAILURE (Status))
502 return (Status);
505 DtInsertSubtable (ParentTable, Subtable);
506 ComponentCount--;
509 SubtableCount--;
510 DtPopSubtable ();
513 /* Subtable: Count of Memory Power State Characteristic structures */
515 DtPopSubtable ();
517 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable);
518 if (ACPI_FAILURE (Status))
520 return (Status);
523 ParentTable = DtPeekSubtable ();
524 DtInsertSubtable (ParentTable, Subtable);
525 DtPushSubtable (Subtable);
527 MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer);
528 SubtableCount = MpstDataHeader->CharacteristicsCount;
530 ParentTable = DtPeekSubtable ();
532 /* Subtable: Memory Power State Characteristics structure(s) */
534 while (*PFieldList && SubtableCount)
536 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2,
537 &Subtable);
538 if (ACPI_FAILURE (Status))
540 return (Status);
543 DtInsertSubtable (ParentTable, Subtable);
544 SubtableCount--;
547 DtPopSubtable ();
548 return (AE_OK);
552 /******************************************************************************
554 * FUNCTION: DtCompileMsct
556 * PARAMETERS: List - Current field list pointer
558 * RETURN: Status
560 * DESCRIPTION: Compile MSCT.
562 *****************************************************************************/
564 ACPI_STATUS
565 DtCompileMsct (
566 void **List)
568 ACPI_STATUS Status;
571 Status = DtCompileTwoSubtables (List,
572 AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0);
573 return (Status);
577 /******************************************************************************
579 * FUNCTION: DtCompileMtmr
581 * PARAMETERS: List - Current field list pointer
583 * RETURN: Status
585 * DESCRIPTION: Compile MTMR.
587 *****************************************************************************/
589 ACPI_STATUS
590 DtCompileMtmr (
591 void **List)
593 ACPI_STATUS Status;
596 Status = DtCompileTwoSubtables (List,
597 AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0);
598 return (Status);
602 /******************************************************************************
604 * FUNCTION: DtCompileNfit
606 * PARAMETERS: List - Current field list pointer
608 * RETURN: Status
610 * DESCRIPTION: Compile NFIT.
612 *****************************************************************************/
614 ACPI_STATUS
615 DtCompileNfit (
616 void **List)
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;
630 /* Main table */
632 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit,
633 &Subtable);
634 if (ACPI_FAILURE (Status))
636 return (Status);
639 ParentTable = DtPeekSubtable ();
640 DtInsertSubtable (ParentTable, Subtable);
641 DtPushSubtable (Subtable);
643 /* Subtables */
645 while (*PFieldList)
647 SubtableStart = *PFieldList;
648 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr,
649 &Subtable);
650 if (ACPI_FAILURE (Status))
652 return (Status);
655 ParentTable = DtPeekSubtable ();
656 DtInsertSubtable (ParentTable, Subtable);
657 DtPushSubtable (Subtable);
659 NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
661 switch (NfitHeader->Type)
663 case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
665 InfoTable = AcpiDmTableInfoNfit0;
666 break;
668 case ACPI_NFIT_TYPE_MEMORY_MAP:
670 InfoTable = AcpiDmTableInfoNfit1;
671 break;
673 case ACPI_NFIT_TYPE_INTERLEAVE:
675 Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer);
676 InfoTable = AcpiDmTableInfoNfit2;
677 break;
679 case ACPI_NFIT_TYPE_SMBIOS:
681 InfoTable = AcpiDmTableInfoNfit3;
682 break;
684 case ACPI_NFIT_TYPE_CONTROL_REGION:
686 InfoTable = AcpiDmTableInfoNfit4;
687 break;
689 case ACPI_NFIT_TYPE_DATA_REGION:
691 InfoTable = AcpiDmTableInfoNfit5;
692 break;
694 case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
696 Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer);
697 InfoTable = AcpiDmTableInfoNfit6;
698 break;
700 case ACPI_NFIT_TYPE_CAPABILITIES:
702 InfoTable = AcpiDmTableInfoNfit7;
703 break;
705 default:
707 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT");
708 return (AE_ERROR);
711 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
712 if (ACPI_FAILURE (Status))
714 return (Status);
717 ParentTable = DtPeekSubtable ();
718 DtInsertSubtable (ParentTable, Subtable);
719 DtPopSubtable ();
721 switch (NfitHeader->Type)
723 case ACPI_NFIT_TYPE_INTERLEAVE:
725 Count = 0;
726 DtPushSubtable (Subtable);
727 while (*PFieldList)
729 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a,
730 &Subtable);
731 if (ACPI_FAILURE (Status))
733 return (Status);
736 if (!Subtable)
738 DtPopSubtable ();
739 break;
742 ParentTable = DtPeekSubtable ();
743 DtInsertSubtable (ParentTable, Subtable);
744 Count++;
747 Interleave->LineCount = Count;
748 break;
750 case ACPI_NFIT_TYPE_SMBIOS:
752 if (*PFieldList)
754 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a,
755 &Subtable);
756 if (ACPI_FAILURE (Status))
758 return (Status);
761 if (Subtable)
763 DtInsertSubtable (ParentTable, Subtable);
766 break;
768 case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
770 Count = 0;
771 DtPushSubtable (Subtable);
772 while (*PFieldList)
774 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a,
775 &Subtable);
776 if (ACPI_FAILURE (Status))
778 return (Status);
781 if (!Subtable)
783 DtPopSubtable ();
784 break;
787 ParentTable = DtPeekSubtable ();
788 DtInsertSubtable (ParentTable, Subtable);
789 Count++;
792 Hint->HintCount = (UINT16) Count;
793 break;
795 default:
796 break;
800 return (AE_OK);
804 /******************************************************************************
806 * FUNCTION: DtCompilePcct
808 * PARAMETERS: List - Current field list pointer
810 * RETURN: Status
812 * DESCRIPTION: Compile PCCT.
814 *****************************************************************************/
816 ACPI_STATUS
817 DtCompilePcct (
818 void **List)
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;
829 /* Main table */
831 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct,
832 &Subtable);
833 if (ACPI_FAILURE (Status))
835 return (Status);
838 ParentTable = DtPeekSubtable ();
839 DtInsertSubtable (ParentTable, Subtable);
841 /* Subtables */
843 while (*PFieldList)
845 SubtableStart = *PFieldList;
846 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr,
847 &Subtable);
848 if (ACPI_FAILURE (Status))
850 return (Status);
853 ParentTable = DtPeekSubtable ();
854 DtInsertSubtable (ParentTable, Subtable);
855 DtPushSubtable (Subtable);
857 PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
859 switch (PcctHeader->Type)
861 case ACPI_PCCT_TYPE_GENERIC_SUBSPACE:
863 InfoTable = AcpiDmTableInfoPcct0;
864 break;
866 case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE:
868 InfoTable = AcpiDmTableInfoPcct1;
869 break;
871 case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2:
873 InfoTable = AcpiDmTableInfoPcct2;
874 break;
876 case ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE:
878 InfoTable = AcpiDmTableInfoPcct3;
879 break;
881 case ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE:
883 InfoTable = AcpiDmTableInfoPcct4;
884 break;
886 default:
888 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT");
889 return (AE_ERROR);
892 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
893 if (ACPI_FAILURE (Status))
895 return (Status);
898 ParentTable = DtPeekSubtable ();
899 DtInsertSubtable (ParentTable, Subtable);
900 DtPopSubtable ();
903 return (AE_OK);
907 /******************************************************************************
909 * FUNCTION: DtCompilePdtt
911 * PARAMETERS: List - Current field list pointer
913 * RETURN: Status
915 * DESCRIPTION: Compile PDTT.
917 *****************************************************************************/
919 ACPI_STATUS
920 DtCompilePdtt (
921 void **List)
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;
931 /* Main table */
933 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt, &Subtable);
934 if (ACPI_FAILURE (Status))
936 return (Status);
939 ParentTable = DtPeekSubtable ();
940 DtInsertSubtable (ParentTable, Subtable);
942 PdttHeader = ACPI_CAST_PTR (ACPI_TABLE_PDTT, ParentTable->Buffer);
943 PdttHeader->ArrayOffset = sizeof (ACPI_TABLE_PDTT);
945 /* There is only one type of subtable at this time, no need to decode */
947 while (*PFieldList)
949 /* List of subchannel IDs, each 2 bytes */
951 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt0,
952 &Subtable);
953 if (ACPI_FAILURE (Status))
955 return (Status);
958 DtInsertSubtable (ParentTable, Subtable);
959 Count++;
962 PdttHeader->TriggerCount = (UINT8) Count;
963 return (AE_OK);
967 /******************************************************************************
969 * FUNCTION: DtCompilePmtt
971 * PARAMETERS: List - Current field list pointer
973 * RETURN: Status
975 * DESCRIPTION: Compile PMTT.
977 *****************************************************************************/
979 ACPI_STATUS
980 DtCompilePmtt (
981 void **List)
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;
994 /* Main table */
996 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable);
997 if (ACPI_FAILURE (Status))
999 return (Status);
1002 ParentTable = DtPeekSubtable ();
1003 DtInsertSubtable (ParentTable, Subtable);
1004 DtPushSubtable (Subtable);
1006 while (*PFieldList)
1008 SubtableStart = *PFieldList;
1009 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr,
1010 &Subtable);
1011 if (ACPI_FAILURE (Status))
1013 return (Status);
1016 PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer);
1017 while (PrevType >= PmttHeader->Type)
1019 DtPopSubtable ();
1021 if (PrevType == ACPI_PMTT_TYPE_SOCKET)
1023 break;
1026 PrevType--;
1029 PrevType = PmttHeader->Type;
1031 ParentTable = DtPeekSubtable ();
1032 DtInsertSubtable (ParentTable, Subtable);
1033 DtPushSubtable (Subtable);
1035 switch (PmttHeader->Type)
1037 case ACPI_PMTT_TYPE_SOCKET:
1039 /* Subtable: Socket Structure */
1041 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0,
1042 &Subtable);
1043 if (ACPI_FAILURE (Status))
1045 return (Status);
1048 ParentTable = DtPeekSubtable ();
1049 DtInsertSubtable (ParentTable, Subtable);
1050 break;
1052 case ACPI_PMTT_TYPE_CONTROLLER:
1054 /* Subtable: Memory Controller Structure */
1056 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1,
1057 &Subtable);
1058 if (ACPI_FAILURE (Status))
1060 return (Status);
1063 ParentTable = DtPeekSubtable ();
1064 DtInsertSubtable (ParentTable, Subtable);
1066 PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER,
1067 (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER)));
1068 DomainCount = PmttController->DomainCount;
1070 while (DomainCount)
1072 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a,
1073 &Subtable);
1074 if (ACPI_FAILURE (Status))
1076 return (Status);
1079 DtInsertSubtable (ParentTable, Subtable);
1080 DomainCount--;
1082 break;
1084 case ACPI_PMTT_TYPE_DIMM:
1086 /* Subtable: Physical Component Structure */
1088 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2,
1089 &Subtable);
1090 if (ACPI_FAILURE (Status))
1092 return (Status);
1095 ParentTable = DtPeekSubtable ();
1096 DtInsertSubtable (ParentTable, Subtable);
1097 break;
1099 default:
1101 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT");
1102 return (AE_ERROR);
1106 return (Status);
1110 /******************************************************************************
1112 * FUNCTION: DtCompilePptt
1114 * PARAMETERS: List - Current field list pointer
1116 * RETURN: Status
1118 * DESCRIPTION: Compile PPTT.
1120 *****************************************************************************/
1122 ACPI_STATUS
1123 DtCompilePptt (
1124 void **List)
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;
1136 ParentTable = DtPeekSubtable ();
1137 while (*PFieldList)
1139 SubtableStart = *PFieldList;
1141 /* Compile PPTT subtable header */
1143 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPpttHdr,
1144 &Subtable);
1145 if (ACPI_FAILURE (Status))
1147 return (Status);
1149 DtInsertSubtable (ParentTable, Subtable);
1150 PpttHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1151 PpttHeader->Length = (UINT8)(Subtable->Length);
1153 switch (PpttHeader->Type)
1155 case ACPI_PPTT_TYPE_PROCESSOR:
1157 InfoTable = AcpiDmTableInfoPptt0;
1158 break;
1160 case ACPI_PPTT_TYPE_CACHE:
1162 InfoTable = AcpiDmTableInfoPptt1;
1163 break;
1165 case ACPI_PPTT_TYPE_ID:
1167 InfoTable = AcpiDmTableInfoPptt2;
1168 break;
1170 default:
1172 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PPTT");
1173 return (AE_ERROR);
1176 /* Compile PPTT subtable body */
1178 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1179 if (ACPI_FAILURE (Status))
1181 return (Status);
1183 DtInsertSubtable (ParentTable, Subtable);
1184 PpttHeader->Length += (UINT8)(Subtable->Length);
1186 /* Compile PPTT subtable additionals */
1188 switch (PpttHeader->Type)
1190 case ACPI_PPTT_TYPE_PROCESSOR:
1192 PpttProcessor = ACPI_SUB_PTR (ACPI_PPTT_PROCESSOR,
1193 Subtable->Buffer, sizeof (ACPI_SUBTABLE_HEADER));
1194 if (PpttProcessor)
1196 /* Compile initiator proximity domain list */
1198 PpttProcessor->NumberOfPrivResources = 0;
1199 while (*PFieldList)
1201 Status = DtCompileTable (PFieldList,
1202 AcpiDmTableInfoPptt0a, &Subtable);
1203 if (ACPI_FAILURE (Status))
1205 return (Status);
1207 if (!Subtable)
1209 break;
1212 DtInsertSubtable (ParentTable, Subtable);
1213 PpttHeader->Length += (UINT8)(Subtable->Length);
1214 PpttProcessor->NumberOfPrivResources++;
1217 break;
1219 default:
1221 break;
1225 return (AE_OK);
1229 /******************************************************************************
1231 * FUNCTION: DtCompileRsdt
1233 * PARAMETERS: List - Current field list pointer
1235 * RETURN: Status
1237 * DESCRIPTION: Compile RSDT.
1239 *****************************************************************************/
1241 ACPI_STATUS
1242 DtCompileRsdt (
1243 void **List)
1245 DT_SUBTABLE *Subtable;
1246 DT_SUBTABLE *ParentTable;
1247 DT_FIELD *FieldList = *(DT_FIELD **) List;
1248 UINT32 Address;
1251 ParentTable = DtPeekSubtable ();
1253 while (FieldList)
1255 DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO);
1257 DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable);
1258 DtInsertSubtable (ParentTable, Subtable);
1259 FieldList = FieldList->Next;
1262 return (AE_OK);
1266 /******************************************************************************
1268 * FUNCTION: DtCompileS3pt
1270 * PARAMETERS: PFieldList - Current field list pointer
1272 * RETURN: Status
1274 * DESCRIPTION: Compile S3PT (Pointed to by FPDT)
1276 *****************************************************************************/
1278 ACPI_STATUS
1279 DtCompileS3pt (
1280 DT_FIELD **PFieldList)
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;
1290 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt,
1291 &AslGbl_RootTable);
1292 if (ACPI_FAILURE (Status))
1294 return (Status);
1297 DtPushSubtable (AslGbl_RootTable);
1299 while (*PFieldList)
1301 SubtableStart = *PFieldList;
1302 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr,
1303 &Subtable);
1304 if (ACPI_FAILURE (Status))
1306 return (Status);
1309 ParentTable = DtPeekSubtable ();
1310 DtInsertSubtable (ParentTable, Subtable);
1311 DtPushSubtable (Subtable);
1313 S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
1315 switch (S3ptHeader->Type)
1317 case ACPI_S3PT_TYPE_RESUME:
1319 InfoTable = AcpiDmTableInfoS3pt0;
1320 break;
1322 case ACPI_S3PT_TYPE_SUSPEND:
1324 InfoTable = AcpiDmTableInfoS3pt1;
1325 break;
1327 default:
1329 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT");
1330 return (AE_ERROR);
1333 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1334 if (ACPI_FAILURE (Status))
1336 return (Status);
1339 ParentTable = DtPeekSubtable ();
1340 DtInsertSubtable (ParentTable, Subtable);
1341 DtPopSubtable ();
1344 return (AE_OK);
1348 /******************************************************************************
1350 * FUNCTION: DtCompileSdev
1352 * PARAMETERS: List - Current field list pointer
1354 * RETURN: Status
1356 * DESCRIPTION: Compile SDEV.
1358 *****************************************************************************/
1360 ACPI_STATUS
1361 DtCompileSdev (
1362 void **List)
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;
1376 /* Subtables */
1378 while (*PFieldList)
1380 /* Compile common SDEV subtable header */
1382 SubtableStart = *PFieldList;
1383 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevHdr,
1384 &Subtable);
1385 if (ACPI_FAILURE (Status))
1387 return (Status);
1390 ParentTable = DtPeekSubtable ();
1391 DtInsertSubtable (ParentTable, Subtable);
1392 DtPushSubtable (Subtable);
1394 SdevHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer);
1395 SdevHeader->Length = (UINT8)(sizeof (ACPI_SDEV_HEADER));
1397 switch (SdevHeader->Type)
1399 case ACPI_SDEV_TYPE_NAMESPACE_DEVICE:
1401 InfoTable = AcpiDmTableInfoSdev0;
1402 Namesp = ACPI_CAST_PTR (ACPI_SDEV_NAMESPACE, Subtable->Buffer);
1403 break;
1405 case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
1407 InfoTable = AcpiDmTableInfoSdev1;
1408 Pcie = ACPI_CAST_PTR (ACPI_SDEV_PCIE, Subtable->Buffer);
1409 break;
1411 default:
1413 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV");
1414 return (AE_ERROR);
1417 /* Compile SDEV subtable body */
1419 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1420 if (ACPI_FAILURE (Status))
1422 return (Status);
1425 ParentTable = DtPeekSubtable ();
1426 DtInsertSubtable (ParentTable, Subtable);
1428 /* Optional data fields are appended to the main subtable body */
1430 switch (SdevHeader->Type)
1432 case ACPI_SDEV_TYPE_NAMESPACE_DEVICE:
1434 /* Append DeviceId namespace string */
1436 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0a,
1437 &Subtable);
1438 if (ACPI_FAILURE (Status))
1440 return (Status);
1443 if (!Subtable)
1445 break;
1448 ParentTable = DtPeekSubtable ();
1449 DtInsertSubtable (ParentTable, Subtable);
1451 Namesp->DeviceIdOffset = sizeof (ACPI_SDEV_NAMESPACE);
1452 Namesp->DeviceIdLength = (UINT16) Subtable->Length;
1454 /* Append Vendor data */
1456 Namesp->VendorDataLength = 0;
1457 Namesp->VendorDataOffset = 0;
1459 if (*PFieldList)
1461 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b,
1462 &Subtable);
1463 if (ACPI_FAILURE (Status))
1465 return (Status);
1468 if (Subtable)
1470 ParentTable = DtPeekSubtable ();
1471 DtInsertSubtable (ParentTable, Subtable);
1473 Namesp->VendorDataOffset =
1474 Namesp->DeviceIdOffset + Namesp->DeviceIdLength;
1475 Namesp->VendorDataLength =
1476 (UINT16) Subtable->Length;
1480 /* Final size of entire namespace structure */
1482 SdevHeader->Length = (UINT16) (sizeof (ACPI_SDEV_NAMESPACE) +
1483 Subtable->Length + Namesp->DeviceIdLength);
1484 break;
1486 case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
1488 /* Append the PCIe path info first */
1490 EntryCount = 0;
1491 while (*PFieldList && !strcmp ((*PFieldList)->Name, "Device"))
1493 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1a,
1494 &Subtable);
1495 if (ACPI_FAILURE (Status))
1497 return (Status);
1500 if (!Subtable)
1502 DtPopSubtable ();
1503 break;
1506 ParentTable = DtPeekSubtable ();
1507 DtInsertSubtable (ParentTable, Subtable);
1508 EntryCount++;
1511 /* Path offset will point immediately after the main subtable */
1513 Pcie->PathOffset = sizeof (ACPI_SDEV_PCIE);
1514 Pcie->PathLength = (UINT16)
1515 (EntryCount * sizeof (ACPI_SDEV_PCIE_PATH));
1517 /* Append the Vendor Data last */
1519 Pcie->VendorDataLength = 0;
1520 Pcie->VendorDataOffset = 0;
1522 if (*PFieldList)
1524 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b,
1525 &Subtable);
1526 if (ACPI_FAILURE (Status))
1528 return (Status);
1531 if (Subtable)
1533 ParentTable = DtPeekSubtable ();
1534 DtInsertSubtable (ParentTable, Subtable);
1536 Pcie->VendorDataOffset =
1537 Pcie->PathOffset + Pcie->PathLength;
1538 Pcie->VendorDataLength = (UINT16)
1539 Subtable->Length;
1543 SdevHeader->Length =
1544 sizeof (ACPI_SDEV_PCIE) +
1545 Pcie->PathLength + Pcie->VendorDataLength;
1546 break;
1548 default:
1550 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV");
1551 return (AE_ERROR);
1554 DtPopSubtable ();
1557 return (AE_OK);
1561 /******************************************************************************
1563 * FUNCTION: DtCompileSlic
1565 * PARAMETERS: List - Current field list pointer
1567 * RETURN: Status
1569 * DESCRIPTION: Compile SLIC.
1571 *****************************************************************************/
1573 ACPI_STATUS
1574 DtCompileSlic (
1575 void **List)
1577 ACPI_STATUS Status;
1578 DT_SUBTABLE *Subtable;
1579 DT_SUBTABLE *ParentTable;
1580 DT_FIELD **PFieldList = (DT_FIELD **) List;
1583 while (*PFieldList)
1585 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic,
1586 &Subtable);
1587 if (ACPI_FAILURE (Status))
1589 return (Status);
1592 ParentTable = DtPeekSubtable ();
1593 DtInsertSubtable (ParentTable, Subtable);
1594 DtPushSubtable (Subtable);
1595 DtPopSubtable ();
1598 return (AE_OK);
1602 /******************************************************************************
1604 * FUNCTION: DtCompileSlit
1606 * PARAMETERS: List - Current field list pointer
1608 * RETURN: Status
1610 * DESCRIPTION: Compile SLIT.
1612 *****************************************************************************/
1614 ACPI_STATUS
1615 DtCompileSlit (
1616 void **List)
1618 ACPI_STATUS Status;
1619 DT_SUBTABLE *Subtable;
1620 DT_SUBTABLE *ParentTable;
1621 DT_FIELD **PFieldList = (DT_FIELD **) List;
1622 DT_FIELD *FieldList;
1623 UINT32 Localities;
1624 UINT8 *LocalityBuffer;
1627 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
1628 &Subtable);
1629 if (ACPI_FAILURE (Status))
1631 return (Status);
1634 ParentTable = DtPeekSubtable ();
1635 DtInsertSubtable (ParentTable, Subtable);
1637 Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
1638 LocalityBuffer = UtLocalCalloc (Localities);
1640 /* Compile each locality buffer */
1642 FieldList = *PFieldList;
1643 while (FieldList)
1645 DtCompileBuffer (LocalityBuffer,
1646 FieldList->Value, FieldList, Localities);
1648 DtCreateSubtable (LocalityBuffer, Localities, &Subtable);
1649 DtInsertSubtable (ParentTable, Subtable);
1650 FieldList = FieldList->Next;
1653 ACPI_FREE (LocalityBuffer);
1654 return (AE_OK);
1658 /******************************************************************************
1660 * FUNCTION: DtCompileSrat
1662 * PARAMETERS: List - Current field list pointer
1664 * RETURN: Status
1666 * DESCRIPTION: Compile SRAT.
1668 *****************************************************************************/
1670 ACPI_STATUS
1671 DtCompileSrat (
1672 void **List)
1674 ACPI_STATUS Status;
1675 DT_SUBTABLE *Subtable;
1676 DT_SUBTABLE *ParentTable;
1677 DT_FIELD **PFieldList = (DT_FIELD **) List;
1678 DT_FIELD *SubtableStart;
1679 ACPI_SUBTABLE_HEADER *SratHeader;
1680 ACPI_DMTABLE_INFO *InfoTable;
1683 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat,
1684 &Subtable);
1685 if (ACPI_FAILURE (Status))
1687 return (Status);
1690 ParentTable = DtPeekSubtable ();
1691 DtInsertSubtable (ParentTable, Subtable);
1693 while (*PFieldList)
1695 SubtableStart = *PFieldList;
1696 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr,
1697 &Subtable);
1698 if (ACPI_FAILURE (Status))
1700 return (Status);
1703 ParentTable = DtPeekSubtable ();
1704 DtInsertSubtable (ParentTable, Subtable);
1705 DtPushSubtable (Subtable);
1707 SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1709 switch (SratHeader->Type)
1711 case ACPI_SRAT_TYPE_CPU_AFFINITY:
1713 InfoTable = AcpiDmTableInfoSrat0;
1714 break;
1716 case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
1718 InfoTable = AcpiDmTableInfoSrat1;
1719 break;
1721 case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
1723 InfoTable = AcpiDmTableInfoSrat2;
1724 break;
1726 case ACPI_SRAT_TYPE_GICC_AFFINITY:
1728 InfoTable = AcpiDmTableInfoSrat3;
1729 break;
1731 case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
1733 InfoTable = AcpiDmTableInfoSrat4;
1734 break;
1736 default:
1738 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT");
1739 return (AE_ERROR);
1742 Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
1743 if (ACPI_FAILURE (Status))
1745 return (Status);
1748 ParentTable = DtPeekSubtable ();
1749 DtInsertSubtable (ParentTable, Subtable);
1750 DtPopSubtable ();
1753 return (AE_OK);
1757 /******************************************************************************
1759 * FUNCTION: DtCompileStao
1761 * PARAMETERS: PFieldList - Current field list pointer
1763 * RETURN: Status
1765 * DESCRIPTION: Compile STAO.
1767 *****************************************************************************/
1769 ACPI_STATUS
1770 DtCompileStao (
1771 void **List)
1773 DT_FIELD **PFieldList = (DT_FIELD **) List;
1774 DT_SUBTABLE *Subtable;
1775 DT_SUBTABLE *ParentTable;
1776 ACPI_STATUS Status;
1779 /* Compile the main table */
1781 Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao,
1782 &Subtable);
1783 if (ACPI_FAILURE (Status))
1785 return (Status);
1788 ParentTable = DtPeekSubtable ();
1789 DtInsertSubtable (ParentTable, Subtable);
1791 /* Compile each ASCII namestring as a subtable */
1793 while (*PFieldList)
1795 Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr,
1796 &Subtable);
1797 if (ACPI_FAILURE (Status))
1799 return (Status);
1802 ParentTable = DtPeekSubtable ();
1803 DtInsertSubtable (ParentTable, Subtable);
1806 return (AE_OK);
1810 /******************************************************************************
1812 * FUNCTION: DtCompileTcpa
1814 * PARAMETERS: PFieldList - Current field list pointer
1816 * RETURN: Status
1818 * DESCRIPTION: Compile TCPA.
1820 *****************************************************************************/
1822 ACPI_STATUS
1823 DtCompileTcpa (
1824 void **List)
1826 DT_FIELD **PFieldList = (DT_FIELD **) List;
1827 DT_SUBTABLE *Subtable;
1828 ACPI_TABLE_TCPA_HDR *TcpaHeader;
1829 DT_SUBTABLE *ParentTable;
1830 ACPI_STATUS Status;
1833 /* Compile the main table */
1835 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr,
1836 &Subtable);
1837 if (ACPI_FAILURE (Status))
1839 return (Status);
1842 ParentTable = DtPeekSubtable ();
1843 DtInsertSubtable (ParentTable, Subtable);
1846 * Examine the PlatformClass field to determine the table type.
1847 * Either a client or server table. Only one.
1849 TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer);
1851 switch (TcpaHeader->PlatformClass)
1853 case ACPI_TCPA_CLIENT_TABLE:
1855 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient,
1856 &Subtable);
1857 break;
1859 case ACPI_TCPA_SERVER_TABLE:
1861 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer,
1862 &Subtable);
1863 break;
1865 default:
1867 AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
1868 TcpaHeader->PlatformClass);
1869 Status = AE_ERROR;
1870 break;
1873 ParentTable = DtPeekSubtable ();
1874 DtInsertSubtable (ParentTable, Subtable);
1875 return (Status);
1879 /******************************************************************************
1881 * FUNCTION: DtCompileTpm2
1883 * PARAMETERS: PFieldList - Current field list pointer
1885 * RETURN: Status
1887 * DESCRIPTION: Compile TPM2.
1889 *****************************************************************************/
1891 ACPI_STATUS
1892 DtCompileTpm2 (
1893 void **List)
1895 DT_FIELD **PFieldList = (DT_FIELD **) List;
1896 DT_SUBTABLE *Subtable;
1897 ACPI_TABLE_TPM2 *Tpm2Header;
1898 DT_SUBTABLE *ParentTable;
1899 ACPI_STATUS Status = AE_OK;
1902 /* Compile the main table */
1904 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2,
1905 &Subtable);
1906 if (ACPI_FAILURE (Status))
1908 return (Status);
1911 ParentTable = DtPeekSubtable ();
1912 DtInsertSubtable (ParentTable, Subtable);
1914 Tpm2Header = ACPI_CAST_PTR (ACPI_TABLE_TPM2, ParentTable->Buffer);
1916 /* Method parameters */
1917 /* Optional: Log area minimum length */
1918 /* Optional: Log area start address */
1919 /* TBD: Optional fields above not fully implemented (not optional at this time) */
1921 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2a,
1922 &Subtable);
1923 if (ACPI_FAILURE (Status))
1925 return (Status);
1928 ParentTable = DtPeekSubtable ();
1929 DtInsertSubtable (ParentTable, Subtable);
1932 /* Subtable type depends on the StartMethod */
1934 switch (Tpm2Header->StartMethod)
1936 case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
1938 /* Subtable specific to to ARM_SMC */
1940 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm211,
1941 &Subtable);
1942 if (ACPI_FAILURE (Status))
1944 return (Status);
1947 ParentTable = DtPeekSubtable ();
1948 DtInsertSubtable (ParentTable, Subtable);
1949 break;
1951 case ACPI_TPM2_START_METHOD:
1952 case ACPI_TPM2_MEMORY_MAPPED:
1953 case ACPI_TPM2_COMMAND_BUFFER:
1954 case ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD:
1955 break;
1957 case ACPI_TPM2_RESERVED1:
1958 case ACPI_TPM2_RESERVED3:
1959 case ACPI_TPM2_RESERVED4:
1960 case ACPI_TPM2_RESERVED5:
1961 case ACPI_TPM2_RESERVED9:
1962 case ACPI_TPM2_RESERVED10:
1964 AcpiOsPrintf ("\n**** Reserved TPM2 Start Method type 0x%X\n",
1965 Tpm2Header->StartMethod);
1966 Status = AE_ERROR;
1967 break;
1969 case ACPI_TPM2_NOT_ALLOWED:
1970 default:
1972 AcpiOsPrintf ("\n**** Unknown TPM2 Start Method type 0x%X\n",
1973 Tpm2Header->StartMethod);
1974 Status = AE_ERROR;
1975 break;
1978 return (Status);
1982 /******************************************************************************
1984 * FUNCTION: DtGetGenericTableInfo
1986 * PARAMETERS: Name - Generic type name
1988 * RETURN: Info entry
1990 * DESCRIPTION: Obtain table info for a generic name entry
1992 *****************************************************************************/
1994 ACPI_DMTABLE_INFO *
1995 DtGetGenericTableInfo (
1996 char *Name)
1998 ACPI_DMTABLE_INFO *Info;
1999 UINT32 i;
2002 if (!Name)
2004 return (NULL);
2007 /* Search info table for name match */
2009 for (i = 0; ; i++)
2011 Info = AcpiDmTableInfoGeneric[i];
2012 if (Info->Opcode == ACPI_DMT_EXIT)
2014 Info = NULL;
2015 break;
2018 /* Use caseless compare for generic keywords */
2020 if (!AcpiUtStricmp (Name, Info->Name))
2022 break;
2026 return (Info);
2030 /******************************************************************************
2032 * FUNCTION: DtCompileUefi
2034 * PARAMETERS: List - Current field list pointer
2036 * RETURN: Status
2038 * DESCRIPTION: Compile UEFI.
2040 *****************************************************************************/
2042 ACPI_STATUS
2043 DtCompileUefi (
2044 void **List)
2046 ACPI_STATUS Status;
2047 DT_SUBTABLE *Subtable;
2048 DT_SUBTABLE *ParentTable;
2049 DT_FIELD **PFieldList = (DT_FIELD **) List;
2050 UINT16 *DataOffset;
2053 /* Compile the predefined portion of the UEFI table */
2055 Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi,
2056 &Subtable);
2057 if (ACPI_FAILURE (Status))
2059 return (Status);
2062 DataOffset = (UINT16 *) (Subtable->Buffer + 16);
2063 *DataOffset = sizeof (ACPI_TABLE_UEFI);
2065 ParentTable = DtPeekSubtable ();
2066 DtInsertSubtable (ParentTable, Subtable);
2069 * Compile the "generic" portion of the UEFI table. This
2070 * part of the table is not predefined and any of the generic
2071 * operators may be used.
2073 DtCompileGeneric ((void **) PFieldList, NULL, NULL);
2074 return (AE_OK);
2078 /******************************************************************************
2080 * FUNCTION: DtCompileVrtc
2082 * PARAMETERS: List - Current field list pointer
2084 * RETURN: Status
2086 * DESCRIPTION: Compile VRTC.
2088 *****************************************************************************/
2090 ACPI_STATUS
2091 DtCompileVrtc (
2092 void **List)
2094 ACPI_STATUS Status;
2097 Status = DtCompileTwoSubtables (List,
2098 AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0);
2099 return (Status);
2103 /******************************************************************************
2105 * FUNCTION: DtCompileWdat
2107 * PARAMETERS: List - Current field list pointer
2109 * RETURN: Status
2111 * DESCRIPTION: Compile WDAT.
2113 *****************************************************************************/
2115 ACPI_STATUS
2116 DtCompileWdat (
2117 void **List)
2119 ACPI_STATUS Status;
2122 Status = DtCompileTwoSubtables (List,
2123 AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0);
2124 return (Status);
2128 /******************************************************************************
2130 * FUNCTION: DtCompileWpbt
2132 * PARAMETERS: List - Current field list pointer
2134 * RETURN: Status
2136 * DESCRIPTION: Compile WPBT.
2138 *****************************************************************************/
2140 ACPI_STATUS
2141 DtCompileWpbt (
2142 void **List)
2144 DT_FIELD **PFieldList = (DT_FIELD **) List;
2145 DT_SUBTABLE *Subtable;
2146 DT_SUBTABLE *ParentTable;
2147 ACPI_TABLE_WPBT *Table;
2148 ACPI_STATUS Status;
2149 UINT16 Length;
2152 /* Compile the main table */
2154 Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt,
2155 &Subtable);
2156 if (ACPI_FAILURE (Status))
2158 return (Status);
2161 ParentTable = DtPeekSubtable ();
2162 DtInsertSubtable (ParentTable, Subtable);
2164 /* Compile the argument list subtable */
2166 Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0,
2167 &Subtable);
2168 if (ACPI_FAILURE (Status))
2170 return (Status);
2173 /* Extract the length of the Arguments buffer, insert into main table */
2175 Length = (UINT16) Subtable->TotalLength;
2176 Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
2177 Table->ArgumentsLength = Length;
2179 ParentTable = DtPeekSubtable ();
2180 DtInsertSubtable (ParentTable, Subtable);
2181 return (AE_OK);
2185 /******************************************************************************
2187 * FUNCTION: DtCompileXsdt
2189 * PARAMETERS: List - Current field list pointer
2191 * RETURN: Status
2193 * DESCRIPTION: Compile XSDT.
2195 *****************************************************************************/
2197 ACPI_STATUS
2198 DtCompileXsdt (
2199 void **List)
2201 DT_SUBTABLE *Subtable;
2202 DT_SUBTABLE *ParentTable;
2203 DT_FIELD *FieldList = *(DT_FIELD **) List;
2204 UINT64 Address;
2207 ParentTable = DtPeekSubtable ();
2209 while (FieldList)
2211 DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO);
2213 DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable);
2214 DtInsertSubtable (ParentTable, Subtable);
2215 FieldList = FieldList->Next;
2218 return (AE_OK);
2222 /******************************************************************************
2224 * FUNCTION: DtCompileGeneric
2226 * PARAMETERS: List - Current field list pointer
2227 * Name - Field name to end generic compiling
2228 * Length - Compiled table length to return
2230 * RETURN: Status
2232 * DESCRIPTION: Compile generic unknown table.
2234 *****************************************************************************/
2236 ACPI_STATUS
2237 DtCompileGeneric (
2238 void **List,
2239 char *Name,
2240 UINT32 *Length)
2242 ACPI_STATUS Status;
2243 DT_SUBTABLE *Subtable;
2244 DT_SUBTABLE *ParentTable;
2245 DT_FIELD **PFieldList = (DT_FIELD **) List;
2246 ACPI_DMTABLE_INFO *Info;
2249 ParentTable = DtPeekSubtable ();
2252 * Compile the "generic" portion of the table. This
2253 * part of the table is not predefined and any of the generic
2254 * operators may be used.
2257 /* Find any and all labels in the entire generic portion */
2259 DtDetectAllLabels (*PFieldList);
2261 /* Now we can actually compile the parse tree */
2263 if (Length && *Length)
2265 *Length = 0;
2267 while (*PFieldList)
2269 if (Name && !strcmp ((*PFieldList)->Name, Name))
2271 break;
2274 Info = DtGetGenericTableInfo ((*PFieldList)->Name);
2275 if (!Info)
2277 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found",
2278 (*PFieldList)->Name);
2279 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2280 (*PFieldList), AslGbl_MsgBuffer);
2282 *PFieldList = (*PFieldList)->Next;
2283 continue;
2286 Status = DtCompileTable (PFieldList, Info,
2287 &Subtable);
2288 if (ACPI_SUCCESS (Status))
2290 DtInsertSubtable (ParentTable, Subtable);
2291 if (Length)
2293 *Length += Subtable->Length;
2296 else
2298 *PFieldList = (*PFieldList)->Next;
2300 if (Status == AE_NOT_FOUND)
2302 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found",
2303 (*PFieldList)->Name);
2304 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2305 (*PFieldList), AslGbl_MsgBuffer);
2310 return (AE_OK);