Fixed compatibility of output.
[AROS.git] / arch / all-pc / acpica / source / compiler / dttable.c
blob3b84956a6389b515aad6588464aaaee307a7cfcf
1 /******************************************************************************
3 * Module Name: dttable.c - handling for specific ACPI tables
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #define __DTTABLE_C__
46 /* Compile all complex data tables */
48 #include "aslcompiler.h"
49 #include "dtcompiler.h"
51 #define _COMPONENT DT_COMPILER
52 ACPI_MODULE_NAME ("dttable")
55 /* TBD: merge these into dmtbinfo.c? */
57 static ACPI_DMTABLE_INFO TableInfoAsfAddress[] =
59 {ACPI_DMT_BUFFER, 0, "Addresses", 0},
60 {ACPI_DMT_EXIT, 0, NULL, 0}
63 static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] =
65 {ACPI_DMT_PCI_PATH, 0, "PCI Path", 0},
66 {ACPI_DMT_EXIT, 0, NULL, 0}
70 /* TBD: move to acmacros.h */
72 #define ACPI_SUB_PTR(t, a, b) \
73 ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b)))
76 /* Local prototypes */
78 static ACPI_STATUS
79 DtCompileTwoSubtables (
80 void **List,
81 ACPI_DMTABLE_INFO *TableInfo1,
82 ACPI_DMTABLE_INFO *TableInfo2);
85 /******************************************************************************
87 * FUNCTION: DtCompileTwoSubtables
89 * PARAMETERS: List - Current field list pointer
90 * TableInfo1 - Info table 1
91 * TableInfo1 - Info table 2
93 * RETURN: Status
95 * DESCRIPTION: Compile tables with a header and one or more same subtables.
96 * Include CPEP, EINJ, ERST, MCFG, MSCT, WDAT
98 *****************************************************************************/
100 static ACPI_STATUS
101 DtCompileTwoSubtables (
102 void **List,
103 ACPI_DMTABLE_INFO *TableInfo1,
104 ACPI_DMTABLE_INFO *TableInfo2)
106 ACPI_STATUS Status;
107 DT_SUBTABLE *Subtable;
108 DT_SUBTABLE *ParentTable;
109 DT_FIELD **PFieldList = (DT_FIELD **) List;
112 Status = DtCompileTable (PFieldList, TableInfo1, &Subtable, TRUE);
113 if (ACPI_FAILURE (Status))
115 return (Status);
118 ParentTable = DtPeekSubtable ();
119 DtInsertSubtable (ParentTable, Subtable);
121 while (*PFieldList)
123 Status = DtCompileTable (PFieldList, TableInfo2, &Subtable, FALSE);
124 if (ACPI_FAILURE (Status))
126 return (Status);
129 DtInsertSubtable (ParentTable, Subtable);
132 return (AE_OK);
136 /******************************************************************************
138 * FUNCTION: DtCompileFacs
140 * PARAMETERS: PFieldList - Current field list pointer
142 * RETURN: Status
144 * DESCRIPTION: Compile FACS.
146 *****************************************************************************/
148 ACPI_STATUS
149 DtCompileFacs (
150 DT_FIELD **PFieldList)
152 DT_SUBTABLE *Subtable;
153 UINT8 *ReservedBuffer;
154 ACPI_STATUS Status;
155 UINT32 ReservedSize;
158 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFacs,
159 &Gbl_RootTable, TRUE);
160 if (ACPI_FAILURE (Status))
162 return (Status);
165 /* Large FACS reserved area at the end of the table */
167 ReservedSize = (UINT32) sizeof (((ACPI_TABLE_FACS *) NULL)->Reserved1);
168 ReservedBuffer = UtLocalCalloc (ReservedSize);
170 DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
172 ACPI_FREE (ReservedBuffer);
173 DtInsertSubtable (Gbl_RootTable, Subtable);
174 return (AE_OK);
178 /******************************************************************************
180 * FUNCTION: DtCompileRsdp
182 * PARAMETERS: PFieldList - Current field list pointer
184 * RETURN: Status
186 * DESCRIPTION: Compile RSDP.
188 *****************************************************************************/
190 ACPI_STATUS
191 DtCompileRsdp (
192 DT_FIELD **PFieldList)
194 DT_SUBTABLE *Subtable;
195 ACPI_TABLE_RSDP *Rsdp;
196 ACPI_RSDP_EXTENSION *RsdpExtension;
197 ACPI_STATUS Status;
200 /* Compile the "common" RSDP (ACPI 1.0) */
202 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp1,
203 &Gbl_RootTable, TRUE);
204 if (ACPI_FAILURE (Status))
206 return (Status);
209 Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Gbl_RootTable->Buffer);
210 DtSetTableChecksum (&Rsdp->Checksum);
212 if (Rsdp->Revision > 0)
214 /* Compile the "extended" part of the RSDP as a subtable */
216 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRsdp2,
217 &Subtable, TRUE);
218 if (ACPI_FAILURE (Status))
220 return (Status);
223 DtInsertSubtable (Gbl_RootTable, Subtable);
225 /* Set length and extended checksum for entire RSDP */
227 RsdpExtension = ACPI_CAST_PTR (ACPI_RSDP_EXTENSION, Subtable->Buffer);
228 RsdpExtension->Length = Gbl_RootTable->Length + Subtable->Length;
229 DtSetTableChecksum (&RsdpExtension->ExtendedChecksum);
232 return (AE_OK);
236 /******************************************************************************
238 * FUNCTION: DtCompileAsf
240 * PARAMETERS: List - Current field list pointer
242 * RETURN: Status
244 * DESCRIPTION: Compile ASF!.
246 *****************************************************************************/
248 ACPI_STATUS
249 DtCompileAsf (
250 void **List)
252 ACPI_ASF_INFO *AsfTable;
253 DT_SUBTABLE *Subtable;
254 DT_SUBTABLE *ParentTable;
255 ACPI_DMTABLE_INFO *InfoTable;
256 ACPI_DMTABLE_INFO *DataInfoTable = NULL;
257 UINT32 DataCount = 0;
258 ACPI_STATUS Status;
259 UINT32 i;
260 DT_FIELD **PFieldList = (DT_FIELD **) List;
261 DT_FIELD *SubtableStart;
264 while (*PFieldList)
266 SubtableStart = *PFieldList;
267 Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsfHdr,
268 &Subtable, TRUE);
269 if (ACPI_FAILURE (Status))
271 return (Status);
274 ParentTable = DtPeekSubtable ();
275 DtInsertSubtable (ParentTable, Subtable);
276 DtPushSubtable (Subtable);
278 AsfTable = ACPI_CAST_PTR (ACPI_ASF_INFO, Subtable->Buffer);
280 switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */
282 case ACPI_ASF_TYPE_INFO:
284 InfoTable = AcpiDmTableInfoAsf0;
285 break;
287 case ACPI_ASF_TYPE_ALERT:
289 InfoTable = AcpiDmTableInfoAsf1;
290 break;
292 case ACPI_ASF_TYPE_CONTROL:
294 InfoTable = AcpiDmTableInfoAsf2;
295 break;
297 case ACPI_ASF_TYPE_BOOT:
299 InfoTable = AcpiDmTableInfoAsf3;
300 break;
302 case ACPI_ASF_TYPE_ADDRESS:
304 InfoTable = AcpiDmTableInfoAsf4;
305 break;
307 default:
309 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!");
310 return (AE_ERROR);
313 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
314 if (ACPI_FAILURE (Status))
316 return (Status);
319 ParentTable = DtPeekSubtable ();
320 DtInsertSubtable (ParentTable, Subtable);
322 switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */
324 case ACPI_ASF_TYPE_INFO:
326 DataInfoTable = NULL;
327 break;
329 case ACPI_ASF_TYPE_ALERT:
331 DataInfoTable = AcpiDmTableInfoAsf1a;
332 DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT,
333 ACPI_SUB_PTR (UINT8, Subtable->Buffer,
334 sizeof (ACPI_ASF_HEADER)))->Alerts;
335 break;
337 case ACPI_ASF_TYPE_CONTROL:
339 DataInfoTable = AcpiDmTableInfoAsf2a;
340 DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE,
341 ACPI_SUB_PTR (UINT8, Subtable->Buffer,
342 sizeof (ACPI_ASF_HEADER)))->Controls;
343 break;
345 case ACPI_ASF_TYPE_BOOT:
347 DataInfoTable = NULL;
348 break;
350 case ACPI_ASF_TYPE_ADDRESS:
352 DataInfoTable = TableInfoAsfAddress;
353 DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS,
354 ACPI_SUB_PTR (UINT8, Subtable->Buffer,
355 sizeof (ACPI_ASF_HEADER)))->Devices;
356 break;
358 default:
360 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!");
361 return (AE_ERROR);
364 if (DataInfoTable)
366 switch (AsfTable->Header.Type & 0x7F)
368 case ACPI_ASF_TYPE_ADDRESS:
370 while (DataCount > 0)
372 Status = DtCompileTable (PFieldList, DataInfoTable,
373 &Subtable, TRUE);
374 if (ACPI_FAILURE (Status))
376 return (Status);
379 DtInsertSubtable (ParentTable, Subtable);
380 DataCount = DataCount - Subtable->Length;
382 break;
384 default:
386 for (i = 0; i < DataCount; i++)
388 Status = DtCompileTable (PFieldList, DataInfoTable,
389 &Subtable, TRUE);
390 if (ACPI_FAILURE (Status))
392 return (Status);
395 DtInsertSubtable (ParentTable, Subtable);
397 break;
401 DtPopSubtable ();
404 return (AE_OK);
408 /******************************************************************************
410 * FUNCTION: DtCompileCpep
412 * PARAMETERS: List - Current field list pointer
414 * RETURN: Status
416 * DESCRIPTION: Compile CPEP.
418 *****************************************************************************/
420 ACPI_STATUS
421 DtCompileCpep (
422 void **List)
424 ACPI_STATUS Status;
427 Status = DtCompileTwoSubtables (List,
428 AcpiDmTableInfoCpep, AcpiDmTableInfoCpep0);
429 return (Status);
433 /******************************************************************************
435 * FUNCTION: DtCompileCsrt
437 * PARAMETERS: List - Current field list pointer
439 * RETURN: Status
441 * DESCRIPTION: Compile CSRT.
443 *****************************************************************************/
445 ACPI_STATUS
446 DtCompileCsrt (
447 void **List)
449 ACPI_STATUS Status = AE_OK;
450 DT_SUBTABLE *Subtable;
451 DT_SUBTABLE *ParentTable;
452 DT_FIELD **PFieldList = (DT_FIELD **) List;
453 UINT32 DescriptorCount;
454 UINT32 GroupLength;
457 /* Sub-tables (Resource Groups) */
459 while (*PFieldList)
461 /* Resource group subtable */
463 Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt0,
464 &Subtable, TRUE);
465 if (ACPI_FAILURE (Status))
467 return (Status);
470 /* Compute the number of resource descriptors */
472 GroupLength =
473 (ACPI_CAST_PTR (ACPI_CSRT_GROUP,
474 Subtable->Buffer))->Length -
475 (ACPI_CAST_PTR (ACPI_CSRT_GROUP,
476 Subtable->Buffer))->SharedInfoLength -
477 sizeof (ACPI_CSRT_GROUP);
479 DescriptorCount = (GroupLength /
480 sizeof (ACPI_CSRT_DESCRIPTOR));
482 ParentTable = DtPeekSubtable ();
483 DtInsertSubtable (ParentTable, Subtable);
484 DtPushSubtable (Subtable);
486 /* Shared info subtable (One per resource group) */
488 Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt1,
489 &Subtable, TRUE);
490 if (ACPI_FAILURE (Status))
492 return (Status);
495 ParentTable = DtPeekSubtable ();
496 DtInsertSubtable (ParentTable, Subtable);
498 /* Sub-Subtables (Resource Descriptors) */
500 while (*PFieldList && DescriptorCount)
502 Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2,
503 &Subtable, TRUE);
504 if (ACPI_FAILURE (Status))
506 return (Status);
509 ParentTable = DtPeekSubtable ();
510 DtInsertSubtable (ParentTable, Subtable);
511 DescriptorCount--;
514 DtPopSubtable ();
517 return (Status);
521 /******************************************************************************
523 * FUNCTION: DtCompileDmar
525 * PARAMETERS: List - Current field list pointer
527 * RETURN: Status
529 * DESCRIPTION: Compile DMAR.
531 *****************************************************************************/
533 ACPI_STATUS
534 DtCompileDmar (
535 void **List)
537 ACPI_STATUS Status;
538 DT_SUBTABLE *Subtable;
539 DT_SUBTABLE *ParentTable;
540 DT_FIELD **PFieldList = (DT_FIELD **) List;
541 DT_FIELD *SubtableStart;
542 ACPI_DMTABLE_INFO *InfoTable;
543 ACPI_DMAR_HEADER *DmarHeader;
544 ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
545 UINT32 DeviceScopeLength;
546 UINT32 PciPathLength;
549 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE);
550 if (ACPI_FAILURE (Status))
552 return (Status);
555 ParentTable = DtPeekSubtable ();
556 DtInsertSubtable (ParentTable, Subtable);
557 DtPushSubtable (Subtable);
559 while (*PFieldList)
561 /* DMAR Header */
563 SubtableStart = *PFieldList;
564 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarHdr,
565 &Subtable, TRUE);
566 if (ACPI_FAILURE (Status))
568 return (Status);
571 ParentTable = DtPeekSubtable ();
572 DtInsertSubtable (ParentTable, Subtable);
573 DtPushSubtable (Subtable);
575 DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer);
577 switch (DmarHeader->Type)
579 case ACPI_DMAR_TYPE_HARDWARE_UNIT:
581 InfoTable = AcpiDmTableInfoDmar0;
582 break;
584 case ACPI_DMAR_TYPE_RESERVED_MEMORY:
586 InfoTable = AcpiDmTableInfoDmar1;
587 break;
589 case ACPI_DMAR_TYPE_ATSR:
591 InfoTable = AcpiDmTableInfoDmar2;
592 break;
594 case ACPI_DMAR_HARDWARE_AFFINITY:
596 InfoTable = AcpiDmTableInfoDmar3;
597 break;
599 default:
601 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR");
602 return (AE_ERROR);
605 /* DMAR Subtable */
607 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
608 if (ACPI_FAILURE (Status))
610 return (Status);
613 ParentTable = DtPeekSubtable ();
614 DtInsertSubtable (ParentTable, Subtable);
615 DtPushSubtable (Subtable);
617 /* Optional Device Scope subtables */
619 DeviceScopeLength = DmarHeader->Length - Subtable->Length -
620 ParentTable->Length;
621 while (DeviceScopeLength)
623 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope,
624 &Subtable, FALSE);
625 if (Status == AE_NOT_FOUND)
627 break;
630 ParentTable = DtPeekSubtable ();
631 DtInsertSubtable (ParentTable, Subtable);
632 DtPushSubtable (Subtable);
634 DmarDeviceScope = ACPI_CAST_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable->Buffer);
636 /* Optional PCI Paths */
638 PciPathLength = DmarDeviceScope->Length - Subtable->Length;
639 while (PciPathLength)
641 Status = DtCompileTable (PFieldList, TableInfoDmarPciPath,
642 &Subtable, FALSE);
643 if (Status == AE_NOT_FOUND)
645 DtPopSubtable ();
646 break;
649 ParentTable = DtPeekSubtable ();
650 DtInsertSubtable (ParentTable, Subtable);
651 PciPathLength -= Subtable->Length;
654 DtPopSubtable ();
655 DeviceScopeLength -= DmarDeviceScope->Length;
658 DtPopSubtable ();
659 DtPopSubtable ();
662 return (AE_OK);
666 /******************************************************************************
668 * FUNCTION: DtCompileEinj
670 * PARAMETERS: List - Current field list pointer
672 * RETURN: Status
674 * DESCRIPTION: Compile EINJ.
676 *****************************************************************************/
678 ACPI_STATUS
679 DtCompileEinj (
680 void **List)
682 ACPI_STATUS Status;
685 Status = DtCompileTwoSubtables (List,
686 AcpiDmTableInfoEinj, AcpiDmTableInfoEinj0);
687 return (Status);
691 /******************************************************************************
693 * FUNCTION: DtCompileErst
695 * PARAMETERS: List - Current field list pointer
697 * RETURN: Status
699 * DESCRIPTION: Compile ERST.
701 *****************************************************************************/
703 ACPI_STATUS
704 DtCompileErst (
705 void **List)
707 ACPI_STATUS Status;
710 Status = DtCompileTwoSubtables (List,
711 AcpiDmTableInfoErst, AcpiDmTableInfoEinj0);
712 return (Status);
716 /******************************************************************************
718 * FUNCTION: DtCompileFadt
720 * PARAMETERS: List - Current field list pointer
722 * RETURN: Status
724 * DESCRIPTION: Compile FADT.
726 *****************************************************************************/
728 ACPI_STATUS
729 DtCompileFadt (
730 void **List)
732 ACPI_STATUS Status;
733 DT_SUBTABLE *Subtable;
734 DT_SUBTABLE *ParentTable;
735 DT_FIELD **PFieldList = (DT_FIELD **) List;
736 ACPI_TABLE_HEADER *Table;
737 UINT8 Revision;
740 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
741 &Subtable, TRUE);
742 if (ACPI_FAILURE (Status))
744 return (Status);
747 ParentTable = DtPeekSubtable ();
748 DtInsertSubtable (ParentTable, Subtable);
750 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
751 Revision = Table->Revision;
753 if (Revision == 2)
755 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2,
756 &Subtable, TRUE);
757 if (ACPI_FAILURE (Status))
759 return (Status);
762 DtInsertSubtable (ParentTable, Subtable);
764 else if (Revision >= 2)
766 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3,
767 &Subtable, TRUE);
768 if (ACPI_FAILURE (Status))
770 return (Status);
773 DtInsertSubtable (ParentTable, Subtable);
775 if (Revision >= 5)
777 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5,
778 &Subtable, TRUE);
779 if (ACPI_FAILURE (Status))
781 return (Status);
784 DtInsertSubtable (ParentTable, Subtable);
788 return (AE_OK);
792 /******************************************************************************
794 * FUNCTION: DtCompileFpdt
796 * PARAMETERS: List - Current field list pointer
798 * RETURN: Status
800 * DESCRIPTION: Compile FPDT.
802 *****************************************************************************/
804 ACPI_STATUS
805 DtCompileFpdt (
806 void **List)
808 ACPI_STATUS Status;
809 ACPI_FPDT_HEADER *FpdtHeader;
810 DT_SUBTABLE *Subtable;
811 DT_SUBTABLE *ParentTable;
812 ACPI_DMTABLE_INFO *InfoTable;
813 DT_FIELD **PFieldList = (DT_FIELD **) List;
814 DT_FIELD *SubtableStart;
817 while (*PFieldList)
819 SubtableStart = *PFieldList;
820 Status = DtCompileTable (PFieldList, AcpiDmTableInfoFpdtHdr,
821 &Subtable, TRUE);
822 if (ACPI_FAILURE (Status))
824 return (Status);
827 ParentTable = DtPeekSubtable ();
828 DtInsertSubtable (ParentTable, Subtable);
829 DtPushSubtable (Subtable);
831 FpdtHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
833 switch (FpdtHeader->Type)
835 case ACPI_FPDT_TYPE_BOOT:
837 InfoTable = AcpiDmTableInfoFpdt0;
838 break;
840 case ACPI_FPDT_TYPE_S3PERF:
842 InfoTable = AcpiDmTableInfoFpdt1;
843 break;
845 default:
847 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "FPDT");
848 return (AE_ERROR);
849 break;
852 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
853 if (ACPI_FAILURE (Status))
855 return (Status);
858 ParentTable = DtPeekSubtable ();
859 DtInsertSubtable (ParentTable, Subtable);
860 DtPopSubtable ();
863 return (AE_OK);
867 /******************************************************************************
869 * FUNCTION: DtCompileHest
871 * PARAMETERS: List - Current field list pointer
873 * RETURN: Status
875 * DESCRIPTION: Compile HEST.
877 *****************************************************************************/
879 ACPI_STATUS
880 DtCompileHest (
881 void **List)
883 ACPI_STATUS Status;
884 DT_SUBTABLE *Subtable;
885 DT_SUBTABLE *ParentTable;
886 DT_FIELD **PFieldList = (DT_FIELD **) List;
887 DT_FIELD *SubtableStart;
888 ACPI_DMTABLE_INFO *InfoTable;
889 UINT16 Type;
890 UINT32 BankCount;
893 Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest,
894 &Subtable, TRUE);
895 if (ACPI_FAILURE (Status))
897 return (Status);
900 ParentTable = DtPeekSubtable ();
901 DtInsertSubtable (ParentTable, Subtable);
903 while (*PFieldList)
905 /* Get subtable type */
907 SubtableStart = *PFieldList;
908 DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0);
910 switch (Type)
912 case ACPI_HEST_TYPE_IA32_CHECK:
914 InfoTable = AcpiDmTableInfoHest0;
915 break;
917 case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
919 InfoTable = AcpiDmTableInfoHest1;
920 break;
922 case ACPI_HEST_TYPE_IA32_NMI:
924 InfoTable = AcpiDmTableInfoHest2;
925 break;
927 case ACPI_HEST_TYPE_AER_ROOT_PORT:
929 InfoTable = AcpiDmTableInfoHest6;
930 break;
932 case ACPI_HEST_TYPE_AER_ENDPOINT:
934 InfoTable = AcpiDmTableInfoHest7;
935 break;
937 case ACPI_HEST_TYPE_AER_BRIDGE:
939 InfoTable = AcpiDmTableInfoHest8;
940 break;
942 case ACPI_HEST_TYPE_GENERIC_ERROR:
944 InfoTable = AcpiDmTableInfoHest9;
945 break;
947 default:
949 /* Cannot continue on unknown type */
951 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST");
952 return (AE_ERROR);
955 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
956 if (ACPI_FAILURE (Status))
958 return (Status);
961 DtInsertSubtable (ParentTable, Subtable);
964 * Additional subtable data - IA32 Error Bank(s)
966 BankCount = 0;
967 switch (Type)
969 case ACPI_HEST_TYPE_IA32_CHECK:
971 BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK,
972 Subtable->Buffer))->NumHardwareBanks;
973 break;
975 case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
977 BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED,
978 Subtable->Buffer))->NumHardwareBanks;
979 break;
981 default:
983 break;
986 while (BankCount)
988 Status = DtCompileTable (PFieldList, AcpiDmTableInfoHestBank,
989 &Subtable, TRUE);
990 if (ACPI_FAILURE (Status))
992 return (Status);
995 DtInsertSubtable (ParentTable, Subtable);
996 BankCount--;
1000 return (AE_OK);
1004 /******************************************************************************
1006 * FUNCTION: DtCompileIvrs
1008 * PARAMETERS: List - Current field list pointer
1010 * RETURN: Status
1012 * DESCRIPTION: Compile IVRS.
1014 *****************************************************************************/
1016 ACPI_STATUS
1017 DtCompileIvrs (
1018 void **List)
1020 ACPI_STATUS Status;
1021 DT_SUBTABLE *Subtable;
1022 DT_SUBTABLE *ParentTable;
1023 DT_FIELD **PFieldList = (DT_FIELD **) List;
1024 DT_FIELD *SubtableStart;
1025 ACPI_DMTABLE_INFO *InfoTable;
1026 ACPI_IVRS_HEADER *IvrsHeader;
1027 UINT8 EntryType;
1030 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrs,
1031 &Subtable, TRUE);
1032 if (ACPI_FAILURE (Status))
1034 return (Status);
1037 ParentTable = DtPeekSubtable ();
1038 DtInsertSubtable (ParentTable, Subtable);
1040 while (*PFieldList)
1042 SubtableStart = *PFieldList;
1043 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIvrsHdr,
1044 &Subtable, TRUE);
1045 if (ACPI_FAILURE (Status))
1047 return (Status);
1050 ParentTable = DtPeekSubtable ();
1051 DtInsertSubtable (ParentTable, Subtable);
1052 DtPushSubtable (Subtable);
1054 IvrsHeader = ACPI_CAST_PTR (ACPI_IVRS_HEADER, Subtable->Buffer);
1056 switch (IvrsHeader->Type)
1058 case ACPI_IVRS_TYPE_HARDWARE:
1060 InfoTable = AcpiDmTableInfoIvrs0;
1061 break;
1063 case ACPI_IVRS_TYPE_MEMORY1:
1064 case ACPI_IVRS_TYPE_MEMORY2:
1065 case ACPI_IVRS_TYPE_MEMORY3:
1067 InfoTable = AcpiDmTableInfoIvrs1;
1068 break;
1070 default:
1072 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS");
1073 return (AE_ERROR);
1076 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1077 if (ACPI_FAILURE (Status))
1079 return (Status);
1082 ParentTable = DtPeekSubtable ();
1083 DtInsertSubtable (ParentTable, Subtable);
1085 if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE)
1087 while (*PFieldList &&
1088 !ACPI_STRCMP ((*PFieldList)->Name, "Entry Type"))
1090 SubtableStart = *PFieldList;
1091 DtCompileInteger (&EntryType, *PFieldList, 1, 0);
1093 switch (EntryType)
1095 /* 4-byte device entries */
1097 case ACPI_IVRS_TYPE_PAD4:
1098 case ACPI_IVRS_TYPE_ALL:
1099 case ACPI_IVRS_TYPE_SELECT:
1100 case ACPI_IVRS_TYPE_START:
1101 case ACPI_IVRS_TYPE_END:
1103 InfoTable = AcpiDmTableInfoIvrs4;
1104 break;
1106 /* 8-byte entries, type A */
1108 case ACPI_IVRS_TYPE_ALIAS_SELECT:
1109 case ACPI_IVRS_TYPE_ALIAS_START:
1111 InfoTable = AcpiDmTableInfoIvrs8a;
1112 break;
1114 /* 8-byte entries, type B */
1116 case ACPI_IVRS_TYPE_PAD8:
1117 case ACPI_IVRS_TYPE_EXT_SELECT:
1118 case ACPI_IVRS_TYPE_EXT_START:
1120 InfoTable = AcpiDmTableInfoIvrs8b;
1121 break;
1123 /* 8-byte entries, type C */
1125 case ACPI_IVRS_TYPE_SPECIAL:
1127 InfoTable = AcpiDmTableInfoIvrs8c;
1128 break;
1130 default:
1132 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart,
1133 "IVRS Device Entry");
1134 return (AE_ERROR);
1137 Status = DtCompileTable (PFieldList, InfoTable,
1138 &Subtable, TRUE);
1139 if (ACPI_FAILURE (Status))
1141 return (Status);
1144 DtInsertSubtable (ParentTable, Subtable);
1148 DtPopSubtable ();
1151 return (AE_OK);
1155 /******************************************************************************
1157 * FUNCTION: DtCompileMadt
1159 * PARAMETERS: List - Current field list pointer
1161 * RETURN: Status
1163 * DESCRIPTION: Compile MADT.
1165 *****************************************************************************/
1167 ACPI_STATUS
1168 DtCompileMadt (
1169 void **List)
1171 ACPI_STATUS Status;
1172 DT_SUBTABLE *Subtable;
1173 DT_SUBTABLE *ParentTable;
1174 DT_FIELD **PFieldList = (DT_FIELD **) List;
1175 DT_FIELD *SubtableStart;
1176 ACPI_SUBTABLE_HEADER *MadtHeader;
1177 ACPI_DMTABLE_INFO *InfoTable;
1180 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt,
1181 &Subtable, TRUE);
1182 if (ACPI_FAILURE (Status))
1184 return (Status);
1187 ParentTable = DtPeekSubtable ();
1188 DtInsertSubtable (ParentTable, Subtable);
1190 while (*PFieldList)
1192 SubtableStart = *PFieldList;
1193 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr,
1194 &Subtable, TRUE);
1195 if (ACPI_FAILURE (Status))
1197 return (Status);
1200 ParentTable = DtPeekSubtable ();
1201 DtInsertSubtable (ParentTable, Subtable);
1202 DtPushSubtable (Subtable);
1204 MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1206 switch (MadtHeader->Type)
1208 case ACPI_MADT_TYPE_LOCAL_APIC:
1210 InfoTable = AcpiDmTableInfoMadt0;
1211 break;
1213 case ACPI_MADT_TYPE_IO_APIC:
1215 InfoTable = AcpiDmTableInfoMadt1;
1216 break;
1218 case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
1220 InfoTable = AcpiDmTableInfoMadt2;
1221 break;
1223 case ACPI_MADT_TYPE_NMI_SOURCE:
1225 InfoTable = AcpiDmTableInfoMadt3;
1226 break;
1228 case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
1230 InfoTable = AcpiDmTableInfoMadt4;
1231 break;
1233 case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
1235 InfoTable = AcpiDmTableInfoMadt5;
1236 break;
1238 case ACPI_MADT_TYPE_IO_SAPIC:
1240 InfoTable = AcpiDmTableInfoMadt6;
1241 break;
1243 case ACPI_MADT_TYPE_LOCAL_SAPIC:
1245 InfoTable = AcpiDmTableInfoMadt7;
1246 break;
1248 case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
1250 InfoTable = AcpiDmTableInfoMadt8;
1251 break;
1253 case ACPI_MADT_TYPE_LOCAL_X2APIC:
1255 InfoTable = AcpiDmTableInfoMadt9;
1256 break;
1258 case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
1260 InfoTable = AcpiDmTableInfoMadt10;
1261 break;
1263 case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
1265 InfoTable = AcpiDmTableInfoMadt11;
1266 break;
1268 case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
1270 InfoTable = AcpiDmTableInfoMadt12;
1271 break;
1273 default:
1275 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT");
1276 return (AE_ERROR);
1279 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1280 if (ACPI_FAILURE (Status))
1282 return (Status);
1285 ParentTable = DtPeekSubtable ();
1286 DtInsertSubtable (ParentTable, Subtable);
1287 DtPopSubtable ();
1290 return (AE_OK);
1294 /******************************************************************************
1296 * FUNCTION: DtCompileMcfg
1298 * PARAMETERS: List - Current field list pointer
1300 * RETURN: Status
1302 * DESCRIPTION: Compile MCFG.
1304 *****************************************************************************/
1306 ACPI_STATUS
1307 DtCompileMcfg (
1308 void **List)
1310 ACPI_STATUS Status;
1313 Status = DtCompileTwoSubtables (List,
1314 AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0);
1315 return (Status);
1319 /******************************************************************************
1321 * FUNCTION: DtCompileMpst
1323 * PARAMETERS: List - Current field list pointer
1325 * RETURN: Status
1327 * DESCRIPTION: Compile MPST.
1329 *****************************************************************************/
1331 ACPI_STATUS
1332 DtCompileMpst (
1333 void **List)
1335 ACPI_STATUS Status;
1336 DT_SUBTABLE *Subtable;
1337 DT_SUBTABLE *ParentTable;
1338 DT_FIELD **PFieldList = (DT_FIELD **) List;
1339 ACPI_MPST_CHANNEL *MpstChannelInfo;
1340 ACPI_MPST_POWER_NODE *MpstPowerNode;
1341 ACPI_MPST_DATA_HDR *MpstDataHeader;
1342 UINT16 SubtableCount;
1343 UINT32 PowerStateCount;
1344 UINT32 ComponentCount;
1347 /* Main table */
1349 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable, TRUE);
1350 if (ACPI_FAILURE (Status))
1352 return (Status);
1355 ParentTable = DtPeekSubtable ();
1356 DtInsertSubtable (ParentTable, Subtable);
1357 DtPushSubtable (Subtable);
1359 MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer);
1360 SubtableCount = MpstChannelInfo->PowerNodeCount;
1362 while (*PFieldList && SubtableCount)
1364 /* Subtable: Memory Power Node(s) */
1366 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0,
1367 &Subtable, TRUE);
1368 if (ACPI_FAILURE (Status))
1370 return (Status);
1373 ParentTable = DtPeekSubtable ();
1374 DtInsertSubtable (ParentTable, Subtable);
1375 DtPushSubtable (Subtable);
1377 MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer);
1378 PowerStateCount = MpstPowerNode->NumPowerStates;
1379 ComponentCount = MpstPowerNode->NumPhysicalComponents;
1381 ParentTable = DtPeekSubtable ();
1383 /* Sub-subtables - Memory Power State Structure(s) */
1385 while (*PFieldList && PowerStateCount)
1387 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A,
1388 &Subtable, TRUE);
1389 if (ACPI_FAILURE (Status))
1391 return (Status);
1394 DtInsertSubtable (ParentTable, Subtable);
1395 PowerStateCount--;
1398 /* Sub-subtables - Physical Component ID Structure(s) */
1400 while (*PFieldList && ComponentCount)
1402 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B,
1403 &Subtable, TRUE);
1404 if (ACPI_FAILURE (Status))
1406 return (Status);
1409 DtInsertSubtable (ParentTable, Subtable);
1410 ComponentCount--;
1413 SubtableCount--;
1414 DtPopSubtable ();
1417 /* Subtable: Count of Memory Power State Characteristic structures */
1419 DtPopSubtable ();
1421 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable, TRUE);
1422 if (ACPI_FAILURE (Status))
1424 return (Status);
1427 ParentTable = DtPeekSubtable ();
1428 DtInsertSubtable (ParentTable, Subtable);
1429 DtPushSubtable (Subtable);
1431 MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer);
1432 SubtableCount = MpstDataHeader->CharacteristicsCount;
1434 ParentTable = DtPeekSubtable ();
1436 /* Subtable: Memory Power State Characteristics structure(s) */
1438 while (*PFieldList && SubtableCount)
1440 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2,
1441 &Subtable, TRUE);
1442 if (ACPI_FAILURE (Status))
1444 return (Status);
1447 DtInsertSubtable (ParentTable, Subtable);
1448 SubtableCount--;
1451 DtPopSubtable ();
1452 return (AE_OK);
1456 /******************************************************************************
1458 * FUNCTION: DtCompileMsct
1460 * PARAMETERS: List - Current field list pointer
1462 * RETURN: Status
1464 * DESCRIPTION: Compile MSCT.
1466 *****************************************************************************/
1468 ACPI_STATUS
1469 DtCompileMsct (
1470 void **List)
1472 ACPI_STATUS Status;
1475 Status = DtCompileTwoSubtables (List,
1476 AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0);
1477 return (Status);
1481 /******************************************************************************
1483 * FUNCTION: DtCompileMtmr
1485 * PARAMETERS: List - Current field list pointer
1487 * RETURN: Status
1489 * DESCRIPTION: Compile MTMR.
1491 *****************************************************************************/
1493 ACPI_STATUS
1494 DtCompileMtmr (
1495 void **List)
1497 ACPI_STATUS Status;
1500 Status = DtCompileTwoSubtables (List,
1501 AcpiDmTableInfoMtmr, AcpiDmTableInfoMtmr0);
1502 return (Status);
1506 /******************************************************************************
1508 * FUNCTION: DtCompilePmtt
1510 * PARAMETERS: List - Current field list pointer
1512 * RETURN: Status
1514 * DESCRIPTION: Compile PMTT.
1516 *****************************************************************************/
1518 ACPI_STATUS
1519 DtCompilePmtt (
1520 void **List)
1522 ACPI_STATUS Status;
1523 DT_SUBTABLE *Subtable;
1524 DT_SUBTABLE *ParentTable;
1525 DT_FIELD **PFieldList = (DT_FIELD **) List;
1526 DT_FIELD *SubtableStart;
1527 ACPI_PMTT_HEADER *PmttHeader;
1528 ACPI_PMTT_CONTROLLER *PmttController;
1529 UINT16 DomainCount;
1530 UINT8 PrevType = ACPI_PMTT_TYPE_SOCKET;
1533 /* Main table */
1535 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable, TRUE);
1536 if (ACPI_FAILURE (Status))
1538 return (Status);
1541 ParentTable = DtPeekSubtable ();
1542 DtInsertSubtable (ParentTable, Subtable);
1543 DtPushSubtable (Subtable);
1545 while (*PFieldList)
1547 SubtableStart = *PFieldList;
1548 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttHdr,
1549 &Subtable, TRUE);
1550 if (ACPI_FAILURE (Status))
1552 return (Status);
1555 PmttHeader = ACPI_CAST_PTR (ACPI_PMTT_HEADER, Subtable->Buffer);
1556 while (PrevType >= PmttHeader->Type)
1558 DtPopSubtable ();
1560 if (PrevType == ACPI_PMTT_TYPE_SOCKET)
1562 break;
1564 PrevType--;
1566 PrevType = PmttHeader->Type;
1568 ParentTable = DtPeekSubtable ();
1569 DtInsertSubtable (ParentTable, Subtable);
1570 DtPushSubtable (Subtable);
1572 switch (PmttHeader->Type)
1574 case ACPI_PMTT_TYPE_SOCKET:
1576 /* Subtable: Socket Structure */
1578 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0,
1579 &Subtable, TRUE);
1580 if (ACPI_FAILURE (Status))
1582 return (Status);
1585 ParentTable = DtPeekSubtable ();
1586 DtInsertSubtable (ParentTable, Subtable);
1587 break;
1589 case ACPI_PMTT_TYPE_CONTROLLER:
1591 /* Subtable: Memory Controller Structure */
1593 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1,
1594 &Subtable, TRUE);
1595 if (ACPI_FAILURE (Status))
1597 return (Status);
1600 ParentTable = DtPeekSubtable ();
1601 DtInsertSubtable (ParentTable, Subtable);
1603 PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER,
1604 (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER)));
1605 DomainCount = PmttController->DomainCount;
1607 while (DomainCount)
1609 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1a,
1610 &Subtable, TRUE);
1611 if (ACPI_FAILURE (Status))
1613 return (Status);
1616 DtInsertSubtable (ParentTable, Subtable);
1617 DomainCount--;
1619 break;
1621 case ACPI_PMTT_TYPE_DIMM:
1623 /* Subtable: Physical Component Structure */
1625 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2,
1626 &Subtable, TRUE);
1627 if (ACPI_FAILURE (Status))
1629 return (Status);
1632 ParentTable = DtPeekSubtable ();
1633 DtInsertSubtable (ParentTable, Subtable);
1634 break;
1636 default:
1638 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT");
1639 return (AE_ERROR);
1643 return (Status);
1647 /******************************************************************************
1649 * FUNCTION: DtCompileRsdt
1651 * PARAMETERS: List - Current field list pointer
1653 * RETURN: Status
1655 * DESCRIPTION: Compile RSDT.
1657 *****************************************************************************/
1659 ACPI_STATUS
1660 DtCompileRsdt (
1661 void **List)
1663 DT_SUBTABLE *Subtable;
1664 DT_SUBTABLE *ParentTable;
1665 DT_FIELD *FieldList = *(DT_FIELD **) List;
1666 UINT32 Address;
1669 ParentTable = DtPeekSubtable ();
1671 while (FieldList)
1673 DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO);
1675 DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable);
1676 DtInsertSubtable (ParentTable, Subtable);
1677 FieldList = FieldList->Next;
1680 return (AE_OK);
1684 /******************************************************************************
1686 * FUNCTION: DtCompileS3pt
1688 * PARAMETERS: PFieldList - Current field list pointer
1690 * RETURN: Status
1692 * DESCRIPTION: Compile S3PT (Pointed to by FPDT)
1694 *****************************************************************************/
1696 ACPI_STATUS
1697 DtCompileS3pt (
1698 DT_FIELD **PFieldList)
1700 ACPI_STATUS Status;
1701 ACPI_S3PT_HEADER *S3ptHeader;
1702 DT_SUBTABLE *Subtable;
1703 DT_SUBTABLE *ParentTable;
1704 ACPI_DMTABLE_INFO *InfoTable;
1705 DT_FIELD *SubtableStart;
1708 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt,
1709 &Gbl_RootTable, TRUE);
1710 if (ACPI_FAILURE (Status))
1712 return (Status);
1715 DtPushSubtable (Gbl_RootTable);
1717 while (*PFieldList)
1719 SubtableStart = *PFieldList;
1720 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr,
1721 &Subtable, TRUE);
1722 if (ACPI_FAILURE (Status))
1724 return (Status);
1727 ParentTable = DtPeekSubtable ();
1728 DtInsertSubtable (ParentTable, Subtable);
1729 DtPushSubtable (Subtable);
1731 S3ptHeader = ACPI_CAST_PTR (ACPI_S3PT_HEADER, Subtable->Buffer);
1733 switch (S3ptHeader->Type)
1735 case ACPI_S3PT_TYPE_RESUME:
1737 InfoTable = AcpiDmTableInfoS3pt0;
1738 break;
1740 case ACPI_S3PT_TYPE_SUSPEND:
1742 InfoTable = AcpiDmTableInfoS3pt1;
1743 break;
1745 default:
1747 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT");
1748 return (AE_ERROR);
1751 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1752 if (ACPI_FAILURE (Status))
1754 return (Status);
1757 ParentTable = DtPeekSubtable ();
1758 DtInsertSubtable (ParentTable, Subtable);
1759 DtPopSubtable ();
1762 return (AE_OK);
1766 /******************************************************************************
1768 * FUNCTION: DtCompileSlic
1770 * PARAMETERS: List - Current field list pointer
1772 * RETURN: Status
1774 * DESCRIPTION: Compile SLIC.
1776 *****************************************************************************/
1778 ACPI_STATUS
1779 DtCompileSlic (
1780 void **List)
1782 ACPI_STATUS Status;
1783 DT_SUBTABLE *Subtable;
1784 DT_SUBTABLE *ParentTable;
1785 DT_FIELD **PFieldList = (DT_FIELD **) List;
1786 DT_FIELD *SubtableStart;
1787 ACPI_SLIC_HEADER *SlicHeader;
1788 ACPI_DMTABLE_INFO *InfoTable;
1791 while (*PFieldList)
1793 SubtableStart = *PFieldList;
1794 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlicHdr,
1795 &Subtable, TRUE);
1796 if (ACPI_FAILURE (Status))
1798 return (Status);
1801 ParentTable = DtPeekSubtable ();
1802 DtInsertSubtable (ParentTable, Subtable);
1803 DtPushSubtable (Subtable);
1805 SlicHeader = ACPI_CAST_PTR (ACPI_SLIC_HEADER, Subtable->Buffer);
1807 switch (SlicHeader->Type)
1809 case ACPI_SLIC_TYPE_PUBLIC_KEY:
1811 InfoTable = AcpiDmTableInfoSlic0;
1812 break;
1814 case ACPI_SLIC_TYPE_WINDOWS_MARKER:
1816 InfoTable = AcpiDmTableInfoSlic1;
1817 break;
1819 default:
1821 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SLIC");
1822 return (AE_ERROR);
1825 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1826 if (ACPI_FAILURE (Status))
1828 return (Status);
1831 ParentTable = DtPeekSubtable ();
1832 DtInsertSubtable (ParentTable, Subtable);
1833 DtPopSubtable ();
1836 return (AE_OK);
1840 /******************************************************************************
1842 * FUNCTION: DtCompileSlit
1844 * PARAMETERS: List - Current field list pointer
1846 * RETURN: Status
1848 * DESCRIPTION: Compile SLIT.
1850 *****************************************************************************/
1852 ACPI_STATUS
1853 DtCompileSlit (
1854 void **List)
1856 ACPI_STATUS Status;
1857 DT_SUBTABLE *Subtable;
1858 DT_SUBTABLE *ParentTable;
1859 DT_FIELD **PFieldList = (DT_FIELD **) List;
1860 DT_FIELD *FieldList;
1861 UINT32 Localities;
1862 UINT8 *LocalityBuffer;
1865 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
1866 &Subtable, TRUE);
1867 if (ACPI_FAILURE (Status))
1869 return (Status);
1872 ParentTable = DtPeekSubtable ();
1873 DtInsertSubtable (ParentTable, Subtable);
1875 Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
1876 LocalityBuffer = UtLocalCalloc (Localities);
1878 /* Compile each locality buffer */
1880 FieldList = *PFieldList;
1881 while (FieldList)
1883 DtCompileBuffer (LocalityBuffer,
1884 FieldList->Value, FieldList, Localities);
1886 DtCreateSubtable (LocalityBuffer, Localities, &Subtable);
1887 DtInsertSubtable (ParentTable, Subtable);
1888 FieldList = FieldList->Next;
1891 ACPI_FREE (LocalityBuffer);
1892 return (AE_OK);
1896 /******************************************************************************
1898 * FUNCTION: DtCompileSrat
1900 * PARAMETERS: List - Current field list pointer
1902 * RETURN: Status
1904 * DESCRIPTION: Compile SRAT.
1906 *****************************************************************************/
1908 ACPI_STATUS
1909 DtCompileSrat (
1910 void **List)
1912 ACPI_STATUS Status;
1913 DT_SUBTABLE *Subtable;
1914 DT_SUBTABLE *ParentTable;
1915 DT_FIELD **PFieldList = (DT_FIELD **) List;
1916 DT_FIELD *SubtableStart;
1917 ACPI_SUBTABLE_HEADER *SratHeader;
1918 ACPI_DMTABLE_INFO *InfoTable;
1921 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat,
1922 &Subtable, TRUE);
1923 if (ACPI_FAILURE (Status))
1925 return (Status);
1928 ParentTable = DtPeekSubtable ();
1929 DtInsertSubtable (ParentTable, Subtable);
1931 while (*PFieldList)
1933 SubtableStart = *PFieldList;
1934 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr,
1935 &Subtable, TRUE);
1936 if (ACPI_FAILURE (Status))
1938 return (Status);
1941 ParentTable = DtPeekSubtable ();
1942 DtInsertSubtable (ParentTable, Subtable);
1943 DtPushSubtable (Subtable);
1945 SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer);
1947 switch (SratHeader->Type)
1949 case ACPI_SRAT_TYPE_CPU_AFFINITY:
1951 InfoTable = AcpiDmTableInfoSrat0;
1952 break;
1954 case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
1956 InfoTable = AcpiDmTableInfoSrat1;
1957 break;
1959 case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
1961 InfoTable = AcpiDmTableInfoSrat2;
1962 break;
1964 default:
1966 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT");
1967 return (AE_ERROR);
1970 Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
1971 if (ACPI_FAILURE (Status))
1973 return (Status);
1976 ParentTable = DtPeekSubtable ();
1977 DtInsertSubtable (ParentTable, Subtable);
1978 DtPopSubtable ();
1981 return (AE_OK);
1985 /******************************************************************************
1987 * FUNCTION: DtGetGenericTableInfo
1989 * PARAMETERS: Name - Generic type name
1991 * RETURN: Info entry
1993 * DESCRIPTION: Obtain table info for a generic name entry
1995 *****************************************************************************/
1997 ACPI_DMTABLE_INFO *
1998 DtGetGenericTableInfo (
1999 char *Name)
2001 ACPI_DMTABLE_INFO *Info;
2002 UINT32 i;
2005 if (!Name)
2007 return (NULL);
2010 /* Search info table for name match */
2012 for (i = 0; ; i++)
2014 Info = AcpiDmTableInfoGeneric[i];
2015 if (Info->Opcode == ACPI_DMT_EXIT)
2017 Info = NULL;
2018 break;
2021 /* Use caseless compare for generic keywords */
2023 if (!AcpiUtStricmp (Name, Info->Name))
2025 break;
2029 return (Info);
2033 /******************************************************************************
2035 * FUNCTION: DtCompileUefi
2037 * PARAMETERS: List - Current field list pointer
2039 * RETURN: Status
2041 * DESCRIPTION: Compile UEFI.
2043 *****************************************************************************/
2045 ACPI_STATUS
2046 DtCompileUefi (
2047 void **List)
2049 ACPI_STATUS Status;
2050 DT_SUBTABLE *Subtable;
2051 DT_SUBTABLE *ParentTable;
2052 DT_FIELD **PFieldList = (DT_FIELD **) List;
2053 UINT16 *DataOffset;
2056 /* Compile the predefined portion of the UEFI table */
2058 Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi,
2059 &Subtable, TRUE);
2060 if (ACPI_FAILURE (Status))
2062 return (Status);
2065 DataOffset = (UINT16 *) (Subtable->Buffer + 16);
2066 *DataOffset = sizeof (ACPI_TABLE_UEFI);
2068 ParentTable = DtPeekSubtable ();
2069 DtInsertSubtable (ParentTable, Subtable);
2072 * Compile the "generic" portion of the UEFI table. This
2073 * part of the table is not predefined and any of the generic
2074 * operators may be used.
2077 DtCompileGeneric ((void **) PFieldList);
2079 return (AE_OK);
2083 /******************************************************************************
2085 * FUNCTION: DtCompileVrtc
2087 * PARAMETERS: List - Current field list pointer
2089 * RETURN: Status
2091 * DESCRIPTION: Compile VRTC.
2093 *****************************************************************************/
2095 ACPI_STATUS
2096 DtCompileVrtc (
2097 void **List)
2099 ACPI_STATUS Status;
2102 Status = DtCompileTwoSubtables (List,
2103 AcpiDmTableInfoVrtc, AcpiDmTableInfoVrtc0);
2104 return (Status);
2108 /******************************************************************************
2110 * FUNCTION: DtCompileWdat
2112 * PARAMETERS: List - Current field list pointer
2114 * RETURN: Status
2116 * DESCRIPTION: Compile WDAT.
2118 *****************************************************************************/
2120 ACPI_STATUS
2121 DtCompileWdat (
2122 void **List)
2124 ACPI_STATUS Status;
2127 Status = DtCompileTwoSubtables (List,
2128 AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0);
2129 return (Status);
2133 /******************************************************************************
2135 * FUNCTION: DtCompileXsdt
2137 * PARAMETERS: List - Current field list pointer
2139 * RETURN: Status
2141 * DESCRIPTION: Compile XSDT.
2143 *****************************************************************************/
2145 ACPI_STATUS
2146 DtCompileXsdt (
2147 void **List)
2149 DT_SUBTABLE *Subtable;
2150 DT_SUBTABLE *ParentTable;
2151 DT_FIELD *FieldList = *(DT_FIELD **) List;
2152 UINT64 Address;
2154 ParentTable = DtPeekSubtable ();
2156 while (FieldList)
2158 DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO);
2160 DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable);
2161 DtInsertSubtable (ParentTable, Subtable);
2162 FieldList = FieldList->Next;
2165 return (AE_OK);
2169 /******************************************************************************
2171 * FUNCTION: DtCompileGeneric
2173 * PARAMETERS: List - Current field list pointer
2175 * RETURN: Status
2177 * DESCRIPTION: Compile generic unknown table.
2179 *****************************************************************************/
2181 ACPI_STATUS
2182 DtCompileGeneric (
2183 void **List)
2185 ACPI_STATUS Status;
2186 DT_SUBTABLE *Subtable;
2187 DT_SUBTABLE *ParentTable;
2188 DT_FIELD **PFieldList = (DT_FIELD **) List;
2189 ACPI_DMTABLE_INFO *Info;
2192 ParentTable = DtPeekSubtable ();
2195 * Compile the "generic" portion of the table. This
2196 * part of the table is not predefined and any of the generic
2197 * operators may be used.
2200 /* Find any and all labels in the entire generic portion */
2202 DtDetectAllLabels (*PFieldList);
2204 /* Now we can actually compile the parse tree */
2206 while (*PFieldList)
2208 Info = DtGetGenericTableInfo ((*PFieldList)->Name);
2209 if (!Info)
2211 sprintf (MsgBuffer, "Generic data type \"%s\" not found",
2212 (*PFieldList)->Name);
2213 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2214 (*PFieldList), MsgBuffer);
2216 *PFieldList = (*PFieldList)->Next;
2217 continue;
2220 Status = DtCompileTable (PFieldList, Info,
2221 &Subtable, TRUE);
2222 if (ACPI_SUCCESS (Status))
2224 DtInsertSubtable (ParentTable, Subtable);
2226 else
2228 *PFieldList = (*PFieldList)->Next;
2230 if (Status == AE_NOT_FOUND)
2232 sprintf (MsgBuffer, "Generic data type \"%s\" not found",
2233 (*PFieldList)->Name);
2234 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
2235 (*PFieldList), MsgBuffer);
2240 return (AE_OK);