1 /****************************************************************************** 2 * 3 * Module Name: dttable2.c - handling for specific ACPI tables 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2021, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 /* Compile all complex data tables, signatures starting with L-Z */ 153 154 #include <contrib/dev/acpica/compiler/aslcompiler.h> 155 156 #define _COMPONENT DT_COMPILER 157 ACPI_MODULE_NAME ("dttable2") 158 159 160 /****************************************************************************** 161 * 162 * FUNCTION: DtCompileLpit 163 * 164 * PARAMETERS: List - Current field list pointer 165 * 166 * RETURN: Status 167 * 168 * DESCRIPTION: Compile LPIT. 169 * 170 *****************************************************************************/ 171 172 ACPI_STATUS 173 DtCompileLpit ( 174 void **List) 175 { 176 ACPI_STATUS Status; 177 DT_SUBTABLE *Subtable; 178 DT_SUBTABLE *ParentTable; 179 DT_FIELD **PFieldList = (DT_FIELD **) List; 180 DT_FIELD *SubtableStart; 181 ACPI_DMTABLE_INFO *InfoTable; 182 ACPI_LPIT_HEADER *LpitHeader; 183 184 185 /* Note: Main table consists only of the standard ACPI table header */ 186 187 while (*PFieldList) 188 { 189 SubtableStart = *PFieldList; 190 191 /* LPIT Subtable header */ 192 193 Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr, 194 &Subtable); 195 if (ACPI_FAILURE (Status)) 196 { 197 return (Status); 198 } 199 200 ParentTable = DtPeekSubtable (); 201 DtInsertSubtable (ParentTable, Subtable); 202 DtPushSubtable (Subtable); 203 204 LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer); 205 206 switch (LpitHeader->Type) 207 { 208 case ACPI_LPIT_TYPE_NATIVE_CSTATE: 209 210 InfoTable = AcpiDmTableInfoLpit0; 211 break; 212 213 default: 214 215 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT"); 216 return (AE_ERROR); 217 } 218 219 /* LPIT Subtable */ 220 221 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 222 if (ACPI_FAILURE (Status)) 223 { 224 return (Status); 225 } 226 227 ParentTable = DtPeekSubtable (); 228 DtInsertSubtable (ParentTable, Subtable); 229 DtPopSubtable (); 230 } 231 232 return (AE_OK); 233 } 234 235 236 /****************************************************************************** 237 * 238 * FUNCTION: DtCompileMadt 239 * 240 * PARAMETERS: List - Current field list pointer 241 * 242 * RETURN: Status 243 * 244 * DESCRIPTION: Compile MADT. 245 * 246 *****************************************************************************/ 247 248 ACPI_STATUS 249 DtCompileMadt ( 250 void **List) 251 { 252 ACPI_STATUS Status; 253 DT_SUBTABLE *Subtable; 254 DT_SUBTABLE *ParentTable; 255 DT_FIELD **PFieldList = (DT_FIELD **) List; 256 DT_FIELD *SubtableStart; 257 ACPI_SUBTABLE_HEADER *MadtHeader; 258 ACPI_DMTABLE_INFO *InfoTable; 259 260 261 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadt, 262 &Subtable); 263 if (ACPI_FAILURE (Status)) 264 { 265 return (Status); 266 } 267 268 ParentTable = DtPeekSubtable (); 269 DtInsertSubtable (ParentTable, Subtable); 270 271 while (*PFieldList) 272 { 273 SubtableStart = *PFieldList; 274 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMadtHdr, 275 &Subtable); 276 if (ACPI_FAILURE (Status)) 277 { 278 return (Status); 279 } 280 281 ParentTable = DtPeekSubtable (); 282 DtInsertSubtable (ParentTable, Subtable); 283 DtPushSubtable (Subtable); 284 285 MadtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); 286 287 switch (MadtHeader->Type) 288 { 289 case ACPI_MADT_TYPE_LOCAL_APIC: 290 291 InfoTable = AcpiDmTableInfoMadt0; 292 break; 293 294 case ACPI_MADT_TYPE_IO_APIC: 295 296 InfoTable = AcpiDmTableInfoMadt1; 297 break; 298 299 case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: 300 301 InfoTable = AcpiDmTableInfoMadt2; 302 break; 303 304 case ACPI_MADT_TYPE_NMI_SOURCE: 305 306 InfoTable = AcpiDmTableInfoMadt3; 307 break; 308 309 case ACPI_MADT_TYPE_LOCAL_APIC_NMI: 310 311 InfoTable = AcpiDmTableInfoMadt4; 312 break; 313 314 case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: 315 316 InfoTable = AcpiDmTableInfoMadt5; 317 break; 318 319 case ACPI_MADT_TYPE_IO_SAPIC: 320 321 InfoTable = AcpiDmTableInfoMadt6; 322 break; 323 324 case ACPI_MADT_TYPE_LOCAL_SAPIC: 325 326 InfoTable = AcpiDmTableInfoMadt7; 327 break; 328 329 case ACPI_MADT_TYPE_INTERRUPT_SOURCE: 330 331 InfoTable = AcpiDmTableInfoMadt8; 332 break; 333 334 case ACPI_MADT_TYPE_LOCAL_X2APIC: 335 336 InfoTable = AcpiDmTableInfoMadt9; 337 break; 338 339 case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: 340 341 InfoTable = AcpiDmTableInfoMadt10; 342 break; 343 344 case ACPI_MADT_TYPE_GENERIC_INTERRUPT: 345 346 InfoTable = AcpiDmTableInfoMadt11; 347 break; 348 349 case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: 350 351 InfoTable = AcpiDmTableInfoMadt12; 352 break; 353 354 case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: 355 356 InfoTable = AcpiDmTableInfoMadt13; 357 break; 358 359 case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: 360 361 InfoTable = AcpiDmTableInfoMadt14; 362 break; 363 364 case ACPI_MADT_TYPE_GENERIC_TRANSLATOR: 365 366 InfoTable = AcpiDmTableInfoMadt15; 367 break; 368 369 case ACPI_MADT_TYPE_MULTIPROC_WAKEUP: 370 371 InfoTable = AcpiDmTableInfoMadt16; 372 break; 373 374 default: 375 376 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); 377 return (AE_ERROR); 378 } 379 380 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 381 if (ACPI_FAILURE (Status)) 382 { 383 return (Status); 384 } 385 386 ParentTable = DtPeekSubtable (); 387 DtInsertSubtable (ParentTable, Subtable); 388 DtPopSubtable (); 389 } 390 391 return (AE_OK); 392 } 393 394 395 /****************************************************************************** 396 * 397 * FUNCTION: DtCompileMcfg 398 * 399 * PARAMETERS: List - Current field list pointer 400 * 401 * RETURN: Status 402 * 403 * DESCRIPTION: Compile MCFG. 404 * 405 *****************************************************************************/ 406 407 ACPI_STATUS 408 DtCompileMcfg ( 409 void **List) 410 { 411 ACPI_STATUS Status; 412 413 414 Status = DtCompileTwoSubtables (List, 415 AcpiDmTableInfoMcfg, AcpiDmTableInfoMcfg0); 416 return (Status); 417 } 418 419 420 /****************************************************************************** 421 * 422 * FUNCTION: DtCompileMpst 423 * 424 * PARAMETERS: List - Current field list pointer 425 * 426 * RETURN: Status 427 * 428 * DESCRIPTION: Compile MPST. 429 * 430 *****************************************************************************/ 431 432 ACPI_STATUS 433 DtCompileMpst ( 434 void **List) 435 { 436 ACPI_STATUS Status; 437 DT_SUBTABLE *Subtable; 438 DT_SUBTABLE *ParentTable; 439 DT_FIELD **PFieldList = (DT_FIELD **) List; 440 ACPI_MPST_CHANNEL *MpstChannelInfo; 441 ACPI_MPST_POWER_NODE *MpstPowerNode; 442 ACPI_MPST_DATA_HDR *MpstDataHeader; 443 UINT16 SubtableCount; 444 UINT32 PowerStateCount; 445 UINT32 ComponentCount; 446 447 448 /* Main table */ 449 450 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst, &Subtable); 451 if (ACPI_FAILURE (Status)) 452 { 453 return (Status); 454 } 455 456 ParentTable = DtPeekSubtable (); 457 DtInsertSubtable (ParentTable, Subtable); 458 DtPushSubtable (Subtable); 459 460 MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer); 461 SubtableCount = MpstChannelInfo->PowerNodeCount; 462 463 while (*PFieldList && SubtableCount) 464 { 465 /* Subtable: Memory Power Node(s) */ 466 467 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0, 468 &Subtable); 469 if (ACPI_FAILURE (Status)) 470 { 471 return (Status); 472 } 473 474 ParentTable = DtPeekSubtable (); 475 DtInsertSubtable (ParentTable, Subtable); 476 DtPushSubtable (Subtable); 477 478 MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer); 479 PowerStateCount = MpstPowerNode->NumPowerStates; 480 ComponentCount = MpstPowerNode->NumPhysicalComponents; 481 482 ParentTable = DtPeekSubtable (); 483 484 /* Sub-subtables - Memory Power State Structure(s) */ 485 486 while (*PFieldList && PowerStateCount) 487 { 488 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0A, 489 &Subtable); 490 if (ACPI_FAILURE (Status)) 491 { 492 return (Status); 493 } 494 495 DtInsertSubtable (ParentTable, Subtable); 496 PowerStateCount--; 497 } 498 499 /* Sub-subtables - Physical Component ID Structure(s) */ 500 501 while (*PFieldList && ComponentCount) 502 { 503 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst0B, 504 &Subtable); 505 if (ACPI_FAILURE (Status)) 506 { 507 return (Status); 508 } 509 510 DtInsertSubtable (ParentTable, Subtable); 511 ComponentCount--; 512 } 513 514 SubtableCount--; 515 DtPopSubtable (); 516 } 517 518 /* Subtable: Count of Memory Power State Characteristic structures */ 519 520 DtPopSubtable (); 521 522 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst1, &Subtable); 523 if (ACPI_FAILURE (Status)) 524 { 525 return (Status); 526 } 527 528 ParentTable = DtPeekSubtable (); 529 DtInsertSubtable (ParentTable, Subtable); 530 DtPushSubtable (Subtable); 531 532 MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer); 533 SubtableCount = MpstDataHeader->CharacteristicsCount; 534 535 ParentTable = DtPeekSubtable (); 536 537 /* Subtable: Memory Power State Characteristics structure(s) */ 538 539 while (*PFieldList && SubtableCount) 540 { 541 Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpst2, 542 &Subtable); 543 if (ACPI_FAILURE (Status)) 544 { 545 return (Status); 546 } 547 548 DtInsertSubtable (ParentTable, Subtable); 549 SubtableCount--; 550 } 551 552 DtPopSubtable (); 553 return (AE_OK); 554 } 555 556 557 /****************************************************************************** 558 * 559 * FUNCTION: DtCompileMsct 560 * 561 * PARAMETERS: List - Current field list pointer 562 * 563 * RETURN: Status 564 * 565 * DESCRIPTION: Compile MSCT. 566 * 567 *****************************************************************************/ 568 569 ACPI_STATUS 570 DtCompileMsct ( 571 void **List) 572 { 573 ACPI_STATUS Status; 574 575 576 Status = DtCompileTwoSubtables (List, 577 AcpiDmTableInfoMsct, AcpiDmTableInfoMsct0); 578 return (Status); 579 } 580 581 582 /****************************************************************************** 583 * 584 * FUNCTION: DtCompileNfit 585 * 586 * PARAMETERS: List - Current field list pointer 587 * 588 * RETURN: Status 589 * 590 * DESCRIPTION: Compile NFIT. 591 * 592 *****************************************************************************/ 593 594 ACPI_STATUS 595 DtCompileNfit ( 596 void **List) 597 { 598 ACPI_STATUS Status; 599 DT_SUBTABLE *Subtable; 600 DT_SUBTABLE *ParentTable; 601 DT_FIELD **PFieldList = (DT_FIELD **) List; 602 DT_FIELD *SubtableStart; 603 ACPI_NFIT_HEADER *NfitHeader; 604 ACPI_DMTABLE_INFO *InfoTable; 605 UINT32 Count; 606 ACPI_NFIT_INTERLEAVE *Interleave = NULL; 607 ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL; 608 609 610 /* Main table */ 611 612 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit, 613 &Subtable); 614 if (ACPI_FAILURE (Status)) 615 { 616 return (Status); 617 } 618 619 ParentTable = DtPeekSubtable (); 620 DtInsertSubtable (ParentTable, Subtable); 621 DtPushSubtable (Subtable); 622 623 /* Subtables */ 624 625 while (*PFieldList) 626 { 627 SubtableStart = *PFieldList; 628 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr, 629 &Subtable); 630 if (ACPI_FAILURE (Status)) 631 { 632 return (Status); 633 } 634 635 ParentTable = DtPeekSubtable (); 636 DtInsertSubtable (ParentTable, Subtable); 637 DtPushSubtable (Subtable); 638 639 NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer); 640 641 switch (NfitHeader->Type) 642 { 643 case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: 644 645 InfoTable = AcpiDmTableInfoNfit0; 646 break; 647 648 case ACPI_NFIT_TYPE_MEMORY_MAP: 649 650 InfoTable = AcpiDmTableInfoNfit1; 651 break; 652 653 case ACPI_NFIT_TYPE_INTERLEAVE: 654 655 Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer); 656 InfoTable = AcpiDmTableInfoNfit2; 657 break; 658 659 case ACPI_NFIT_TYPE_SMBIOS: 660 661 InfoTable = AcpiDmTableInfoNfit3; 662 break; 663 664 case ACPI_NFIT_TYPE_CONTROL_REGION: 665 666 InfoTable = AcpiDmTableInfoNfit4; 667 break; 668 669 case ACPI_NFIT_TYPE_DATA_REGION: 670 671 InfoTable = AcpiDmTableInfoNfit5; 672 break; 673 674 case ACPI_NFIT_TYPE_FLUSH_ADDRESS: 675 676 Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer); 677 InfoTable = AcpiDmTableInfoNfit6; 678 break; 679 680 case ACPI_NFIT_TYPE_CAPABILITIES: 681 682 InfoTable = AcpiDmTableInfoNfit7; 683 break; 684 685 default: 686 687 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT"); 688 return (AE_ERROR); 689 } 690 691 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 692 if (ACPI_FAILURE (Status)) 693 { 694 return (Status); 695 } 696 697 ParentTable = DtPeekSubtable (); 698 DtInsertSubtable (ParentTable, Subtable); 699 DtPopSubtable (); 700 701 switch (NfitHeader->Type) 702 { 703 case ACPI_NFIT_TYPE_INTERLEAVE: 704 705 Count = 0; 706 DtPushSubtable (Subtable); 707 while (*PFieldList) 708 { 709 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a, 710 &Subtable); 711 if (ACPI_FAILURE (Status)) 712 { 713 return (Status); 714 } 715 716 if (!Subtable) 717 { 718 DtPopSubtable (); 719 break; 720 } 721 722 ParentTable = DtPeekSubtable (); 723 DtInsertSubtable (ParentTable, Subtable); 724 Count++; 725 } 726 727 Interleave->LineCount = Count; 728 break; 729 730 case ACPI_NFIT_TYPE_SMBIOS: 731 732 if (*PFieldList) 733 { 734 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a, 735 &Subtable); 736 if (ACPI_FAILURE (Status)) 737 { 738 return (Status); 739 } 740 741 if (Subtable) 742 { 743 DtInsertSubtable (ParentTable, Subtable); 744 } 745 } 746 break; 747 748 case ACPI_NFIT_TYPE_FLUSH_ADDRESS: 749 750 Count = 0; 751 DtPushSubtable (Subtable); 752 while (*PFieldList) 753 { 754 Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a, 755 &Subtable); 756 if (ACPI_FAILURE (Status)) 757 { 758 return (Status); 759 } 760 761 if (!Subtable) 762 { 763 DtPopSubtable (); 764 break; 765 } 766 767 ParentTable = DtPeekSubtable (); 768 DtInsertSubtable (ParentTable, Subtable); 769 Count++; 770 } 771 772 Hint->HintCount = (UINT16) Count; 773 break; 774 775 default: 776 break; 777 } 778 } 779 780 return (AE_OK); 781 } 782 783 784 /****************************************************************************** 785 * 786 * FUNCTION: DtCompilePcct 787 * 788 * PARAMETERS: List - Current field list pointer 789 * 790 * RETURN: Status 791 * 792 * DESCRIPTION: Compile PCCT. 793 * 794 *****************************************************************************/ 795 796 ACPI_STATUS 797 DtCompilePcct ( 798 void **List) 799 { 800 ACPI_STATUS Status; 801 DT_SUBTABLE *Subtable; 802 DT_SUBTABLE *ParentTable; 803 DT_FIELD **PFieldList = (DT_FIELD **) List; 804 DT_FIELD *SubtableStart; 805 ACPI_SUBTABLE_HEADER *PcctHeader; 806 ACPI_DMTABLE_INFO *InfoTable; 807 808 809 /* Main table */ 810 811 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, 812 &Subtable); 813 if (ACPI_FAILURE (Status)) 814 { 815 return (Status); 816 } 817 818 ParentTable = DtPeekSubtable (); 819 DtInsertSubtable (ParentTable, Subtable); 820 821 /* Subtables */ 822 823 while (*PFieldList) 824 { 825 SubtableStart = *PFieldList; 826 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr, 827 &Subtable); 828 if (ACPI_FAILURE (Status)) 829 { 830 return (Status); 831 } 832 833 ParentTable = DtPeekSubtable (); 834 DtInsertSubtable (ParentTable, Subtable); 835 DtPushSubtable (Subtable); 836 837 PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); 838 839 switch (PcctHeader->Type) 840 { 841 case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: 842 843 InfoTable = AcpiDmTableInfoPcct0; 844 break; 845 846 case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: 847 848 InfoTable = AcpiDmTableInfoPcct1; 849 break; 850 851 case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2: 852 853 InfoTable = AcpiDmTableInfoPcct2; 854 break; 855 856 case ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE: 857 858 InfoTable = AcpiDmTableInfoPcct3; 859 break; 860 861 case ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE: 862 863 InfoTable = AcpiDmTableInfoPcct4; 864 break; 865 866 case ACPI_PCCT_TYPE_HW_REG_COMM_SUBSPACE: 867 868 InfoTable = AcpiDmTableInfoPcct5; 869 break; 870 871 default: 872 873 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); 874 return (AE_ERROR); 875 } 876 877 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 878 if (ACPI_FAILURE (Status)) 879 { 880 return (Status); 881 } 882 883 ParentTable = DtPeekSubtable (); 884 DtInsertSubtable (ParentTable, Subtable); 885 DtPopSubtable (); 886 } 887 888 return (AE_OK); 889 } 890 891 892 /****************************************************************************** 893 * 894 * FUNCTION: DtCompilePdtt 895 * 896 * PARAMETERS: List - Current field list pointer 897 * 898 * RETURN: Status 899 * 900 * DESCRIPTION: Compile PDTT. 901 * 902 *****************************************************************************/ 903 904 ACPI_STATUS 905 DtCompilePdtt ( 906 void **List) 907 { 908 ACPI_STATUS Status; 909 DT_SUBTABLE *Subtable; 910 DT_SUBTABLE *ParentTable; 911 DT_FIELD **PFieldList = (DT_FIELD **) List; 912 ACPI_TABLE_PDTT *PdttHeader; 913 UINT32 Count = 0; 914 915 916 /* Main table */ 917 918 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt, &Subtable); 919 if (ACPI_FAILURE (Status)) 920 { 921 return (Status); 922 } 923 924 ParentTable = DtPeekSubtable (); 925 DtInsertSubtable (ParentTable, Subtable); 926 927 PdttHeader = ACPI_CAST_PTR (ACPI_TABLE_PDTT, ParentTable->Buffer); 928 PdttHeader->ArrayOffset = sizeof (ACPI_TABLE_PDTT); 929 930 /* There is only one type of subtable at this time, no need to decode */ 931 932 while (*PFieldList) 933 { 934 /* List of subchannel IDs, each 2 bytes */ 935 936 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPdtt0, 937 &Subtable); 938 if (ACPI_FAILURE (Status)) 939 { 940 return (Status); 941 } 942 943 DtInsertSubtable (ParentTable, Subtable); 944 Count++; 945 } 946 947 PdttHeader->TriggerCount = (UINT8) Count; 948 return (AE_OK); 949 } 950 951 952 /****************************************************************************** 953 * 954 * FUNCTION: DtCompilePhat 955 * 956 * PARAMETERS: List - Current field list pointer 957 * 958 * RETURN: Status 959 * 960 * DESCRIPTION: Compile Phat. 961 * 962 *****************************************************************************/ 963 964 ACPI_STATUS 965 DtCompilePhat ( 966 void **List) 967 { 968 ACPI_STATUS Status = AE_OK; 969 DT_SUBTABLE *Subtable; 970 DT_SUBTABLE *ParentTable; 971 DT_FIELD **PFieldList = (DT_FIELD **) List; 972 ACPI_PHAT_HEADER *PhatHeader; 973 ACPI_DMTABLE_INFO *Info; 974 ACPI_PHAT_VERSION_DATA *VersionData; 975 UINT32 RecordCount; 976 977 978 /* The table consist of subtables */ 979 980 while (*PFieldList) 981 { 982 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPhatHdr, &Subtable); 983 if (ACPI_FAILURE (Status)) 984 { 985 return (Status); 986 } 987 988 ParentTable = DtPeekSubtable (); 989 DtInsertSubtable (ParentTable, Subtable); 990 DtPushSubtable (Subtable); 991 992 PhatHeader = ACPI_CAST_PTR (ACPI_PHAT_HEADER, Subtable->Buffer); 993 994 switch (PhatHeader->Type) 995 { 996 case ACPI_PHAT_TYPE_FW_VERSION_DATA: 997 998 Info = AcpiDmTableInfoPhat0; 999 PhatHeader->Length = sizeof (ACPI_PHAT_VERSION_DATA); 1000 break; 1001 1002 case ACPI_PHAT_TYPE_FW_HEALTH_DATA: 1003 1004 Info = AcpiDmTableInfoPhat1; 1005 PhatHeader->Length = sizeof (ACPI_PHAT_HEALTH_DATA); 1006 break; 1007 1008 default: 1009 1010 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, *PFieldList, "PHAT"); 1011 return (AE_ERROR); 1012 1013 break; 1014 } 1015 1016 Status = DtCompileTable (PFieldList, Info, &Subtable); 1017 if (ACPI_FAILURE (Status)) 1018 { 1019 return (Status); 1020 } 1021 1022 ParentTable = DtPeekSubtable (); 1023 DtInsertSubtable (ParentTable, Subtable); 1024 1025 switch (PhatHeader->Type) 1026 { 1027 case ACPI_PHAT_TYPE_FW_VERSION_DATA: 1028 1029 VersionData = ACPI_CAST_PTR (ACPI_PHAT_VERSION_DATA, 1030 (Subtable->Buffer - sizeof (ACPI_PHAT_HEADER))); 1031 RecordCount = VersionData->ElementCount; 1032 1033 while (RecordCount) 1034 { 1035 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPhat0a, 1036 &Subtable); 1037 if (ACPI_FAILURE (Status)) 1038 { 1039 return (Status); 1040 } 1041 ParentTable = DtPeekSubtable (); 1042 DtInsertSubtable (ParentTable, Subtable); 1043 1044 RecordCount--; 1045 PhatHeader->Length += sizeof (ACPI_PHAT_VERSION_ELEMENT); 1046 } 1047 break; 1048 1049 case ACPI_PHAT_TYPE_FW_HEALTH_DATA: 1050 1051 /* Compile device path */ 1052 1053 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPhat1a, &Subtable); 1054 if (ACPI_FAILURE (Status)) 1055 { 1056 return (Status); 1057 } 1058 ParentTable = DtPeekSubtable (); 1059 DtInsertSubtable (ParentTable, Subtable); 1060 1061 PhatHeader->Length += (UINT16) Subtable->Length; 1062 1063 /* Compile vendor specific data */ 1064 1065 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPhat1b, &Subtable); 1066 if (ACPI_FAILURE (Status)) 1067 { 1068 return (Status); 1069 } 1070 ParentTable = DtPeekSubtable (); 1071 DtInsertSubtable (ParentTable, Subtable); 1072 1073 PhatHeader->Length += (UINT16) Subtable->Length; 1074 1075 break; 1076 1077 default: 1078 1079 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, *PFieldList, "PHAT"); 1080 return (AE_ERROR); 1081 } 1082 } 1083 1084 return (Status); 1085 } 1086 1087 1088 /****************************************************************************** 1089 * 1090 * FUNCTION: DtCompilePmtt 1091 * 1092 * PARAMETERS: List - Current field list pointer 1093 * 1094 * RETURN: Status 1095 * 1096 * DESCRIPTION: Compile PMTT. 1097 * 1098 *****************************************************************************/ 1099 1100 ACPI_STATUS 1101 DtCompilePmtt ( 1102 void **List) 1103 { 1104 ACPI_STATUS Status; 1105 DT_SUBTABLE *Subtable; 1106 DT_SUBTABLE *ParentTable; 1107 DT_FIELD **PFieldList = (DT_FIELD **) List; 1108 DT_FIELD *SubtableStart; 1109 UINT16 Type; 1110 1111 1112 /* Main table */ 1113 1114 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt, &Subtable); 1115 if (ACPI_FAILURE (Status)) 1116 { 1117 return (Status); 1118 } 1119 1120 ParentTable = DtPeekSubtable (); 1121 DtInsertSubtable (ParentTable, Subtable); 1122 DtPushSubtable (Subtable); 1123 1124 /* Subtables */ 1125 1126 while (*PFieldList) 1127 { 1128 SubtableStart = *PFieldList; 1129 DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0); 1130 1131 switch (Type) 1132 { 1133 case ACPI_PMTT_TYPE_SOCKET: 1134 1135 /* Subtable: Socket Structure */ 1136 1137 DbgPrint (ASL_DEBUG_OUTPUT, "Compile PMTT_TYPE_SOCKET (0)\n"); 1138 1139 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt0, 1140 &Subtable); 1141 if (ACPI_FAILURE (Status)) 1142 { 1143 return (Status); 1144 } 1145 1146 break; 1147 1148 case ACPI_PMTT_TYPE_CONTROLLER: 1149 1150 /* Subtable: Memory Controller Structure */ 1151 1152 DbgPrint (ASL_DEBUG_OUTPUT, "Compile PMTT_TYPE_CONTROLLER (1)\n"); 1153 1154 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt1, 1155 &Subtable); 1156 if (ACPI_FAILURE (Status)) 1157 { 1158 return (Status); 1159 } 1160 1161 break; 1162 1163 case ACPI_PMTT_TYPE_DIMM: 1164 1165 /* Subtable: Physical Component (DIMM) Structure */ 1166 1167 DbgPrint (ASL_DEBUG_OUTPUT, "Compile PMTT_TYPE_DIMM (2)\n"); 1168 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmtt2, 1169 &Subtable); 1170 if (ACPI_FAILURE (Status)) 1171 { 1172 return (Status); 1173 } 1174 1175 break; 1176 1177 case ACPI_PMTT_TYPE_VENDOR: 1178 1179 /* Subtable: Vendor-specific Structure */ 1180 1181 DbgPrint (ASL_DEBUG_OUTPUT, "Compile PMTT_TYPE_VENDOR(FF)\n"); 1182 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPmttVendor, 1183 &Subtable); 1184 if (ACPI_FAILURE (Status)) 1185 { 1186 return (Status); 1187 } 1188 1189 break; 1190 1191 default: 1192 1193 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PMTT"); 1194 return (AE_ERROR); 1195 } 1196 1197 DtInsertSubtable (ParentTable, Subtable); 1198 } 1199 1200 return (Status); 1201 } 1202 1203 1204 /****************************************************************************** 1205 * 1206 * FUNCTION: DtCompilePptt 1207 * 1208 * PARAMETERS: List - Current field list pointer 1209 * 1210 * RETURN: Status 1211 * 1212 * DESCRIPTION: Compile PPTT. 1213 * 1214 *****************************************************************************/ 1215 1216 ACPI_STATUS 1217 DtCompilePptt ( 1218 void **List) 1219 { 1220 ACPI_STATUS Status; 1221 ACPI_SUBTABLE_HEADER *PpttHeader; 1222 ACPI_PPTT_PROCESSOR *PpttProcessor = NULL; 1223 DT_SUBTABLE *Subtable; 1224 DT_SUBTABLE *ParentTable; 1225 ACPI_DMTABLE_INFO *InfoTable; 1226 DT_FIELD **PFieldList = (DT_FIELD **) List; 1227 DT_FIELD *SubtableStart; 1228 ACPI_TABLE_HEADER *PpttAcpiHeader; 1229 1230 1231 ParentTable = DtPeekSubtable (); 1232 while (*PFieldList) 1233 { 1234 SubtableStart = *PFieldList; 1235 1236 /* Compile PPTT subtable header */ 1237 1238 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPpttHdr, 1239 &Subtable); 1240 if (ACPI_FAILURE (Status)) 1241 { 1242 return (Status); 1243 } 1244 DtInsertSubtable (ParentTable, Subtable); 1245 PpttHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); 1246 PpttHeader->Length = (UINT8)(Subtable->Length); 1247 1248 switch (PpttHeader->Type) 1249 { 1250 case ACPI_PPTT_TYPE_PROCESSOR: 1251 1252 InfoTable = AcpiDmTableInfoPptt0; 1253 break; 1254 1255 case ACPI_PPTT_TYPE_CACHE: 1256 1257 InfoTable = AcpiDmTableInfoPptt1; 1258 break; 1259 1260 case ACPI_PPTT_TYPE_ID: 1261 1262 InfoTable = AcpiDmTableInfoPptt2; 1263 break; 1264 1265 default: 1266 1267 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PPTT"); 1268 return (AE_ERROR); 1269 } 1270 1271 /* Compile PPTT subtable body */ 1272 1273 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 1274 if (ACPI_FAILURE (Status)) 1275 { 1276 return (Status); 1277 } 1278 DtInsertSubtable (ParentTable, Subtable); 1279 PpttHeader->Length += (UINT8)(Subtable->Length); 1280 1281 /* Compile PPTT subtable additionals */ 1282 1283 switch (PpttHeader->Type) 1284 { 1285 case ACPI_PPTT_TYPE_PROCESSOR: 1286 1287 PpttProcessor = ACPI_SUB_PTR (ACPI_PPTT_PROCESSOR, 1288 Subtable->Buffer, sizeof (ACPI_SUBTABLE_HEADER)); 1289 if (PpttProcessor) 1290 { 1291 /* Compile initiator proximity domain list */ 1292 1293 PpttProcessor->NumberOfPrivResources = 0; 1294 while (*PFieldList) 1295 { 1296 Status = DtCompileTable (PFieldList, 1297 AcpiDmTableInfoPptt0a, &Subtable); 1298 if (ACPI_FAILURE (Status)) 1299 { 1300 return (Status); 1301 } 1302 if (!Subtable) 1303 { 1304 break; 1305 } 1306 1307 DtInsertSubtable (ParentTable, Subtable); 1308 PpttHeader->Length += (UINT8)(Subtable->Length); 1309 PpttProcessor->NumberOfPrivResources++; 1310 } 1311 } 1312 break; 1313 1314 case ACPI_PPTT_TYPE_CACHE: 1315 1316 PpttAcpiHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, 1317 AslGbl_RootTable->Buffer); 1318 if (PpttAcpiHeader->Revision < 3) 1319 { 1320 break; 1321 } 1322 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPptt1a, 1323 &Subtable); 1324 DtInsertSubtable (ParentTable, Subtable); 1325 PpttHeader->Length += (UINT8)(Subtable->Length); 1326 break; 1327 1328 default: 1329 1330 break; 1331 } 1332 } 1333 1334 return (AE_OK); 1335 } 1336 1337 1338 /****************************************************************************** 1339 * 1340 * FUNCTION: DtCompilePrmt 1341 * 1342 * PARAMETERS: List - Current field list pointer 1343 * 1344 * RETURN: Status 1345 * 1346 * DESCRIPTION: Compile PRMT. 1347 * 1348 *****************************************************************************/ 1349 1350 ACPI_STATUS 1351 DtCompilePrmt ( 1352 void **List) 1353 { 1354 ACPI_STATUS Status; 1355 ACPI_TABLE_PRMT_HEADER *PrmtHeader; 1356 ACPI_PRMT_MODULE_INFO *PrmtModuleInfo; 1357 DT_SUBTABLE *Subtable; 1358 DT_SUBTABLE *ParentTable; 1359 DT_FIELD **PFieldList = (DT_FIELD **) List; 1360 UINT32 i, j; 1361 1362 ParentTable = DtPeekSubtable (); 1363 1364 /* Compile PRMT subtable header */ 1365 1366 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPrmtHdr, 1367 &Subtable); 1368 if (ACPI_FAILURE (Status)) 1369 { 1370 return (Status); 1371 } 1372 DtInsertSubtable (ParentTable, Subtable); 1373 PrmtHeader = ACPI_CAST_PTR (ACPI_TABLE_PRMT_HEADER, Subtable->Buffer); 1374 1375 for (i = 0; i < PrmtHeader->ModuleInfoCount; i++) 1376 { 1377 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPrmtModule, 1378 &Subtable); 1379 if (ACPI_FAILURE (Status)) 1380 { 1381 return (Status); 1382 } 1383 DtInsertSubtable (ParentTable, Subtable); 1384 PrmtModuleInfo = ACPI_CAST_PTR (ACPI_PRMT_MODULE_INFO, Subtable->Buffer); 1385 1386 for (j = 0; j < PrmtModuleInfo->HandlerInfoCount; j++) 1387 { 1388 Status = DtCompileTable (PFieldList, AcpiDmTableInfoPrmtHandler, 1389 &Subtable); 1390 if (ACPI_FAILURE (Status)) 1391 { 1392 return (Status); 1393 } 1394 DtInsertSubtable (ParentTable, Subtable); 1395 } 1396 } 1397 1398 return (AE_OK); 1399 } 1400 1401 1402 /****************************************************************************** 1403 * 1404 * FUNCTION: DtCompileRgrt 1405 * 1406 * PARAMETERS: List - Current field list pointer 1407 * 1408 * RETURN: Status 1409 * 1410 * DESCRIPTION: Compile RGRT. 1411 * 1412 *****************************************************************************/ 1413 1414 ACPI_STATUS 1415 DtCompileRgrt ( 1416 void **List) 1417 { 1418 ACPI_STATUS Status; 1419 DT_SUBTABLE *Subtable; 1420 DT_SUBTABLE *ParentTable; 1421 DT_FIELD **PFieldList = (DT_FIELD **) List; 1422 1423 1424 /* Compile the main table */ 1425 1426 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRgrt, 1427 &Subtable); 1428 if (ACPI_FAILURE (Status)) 1429 { 1430 return (Status); 1431 } 1432 1433 ParentTable = DtPeekSubtable (); 1434 DtInsertSubtable (ParentTable, Subtable); 1435 1436 /* Compile the "Subtable" -- actually just the binary (PNG) image */ 1437 1438 Status = DtCompileTable (PFieldList, AcpiDmTableInfoRgrt0, 1439 &Subtable); 1440 if (ACPI_FAILURE (Status)) 1441 { 1442 return (Status); 1443 } 1444 1445 DtInsertSubtable (ParentTable, Subtable); 1446 return (AE_OK); 1447 } 1448 1449 1450 /****************************************************************************** 1451 * 1452 * FUNCTION: DtCompileRsdt 1453 * 1454 * PARAMETERS: List - Current field list pointer 1455 * 1456 * RETURN: Status 1457 * 1458 * DESCRIPTION: Compile RSDT. 1459 * 1460 *****************************************************************************/ 1461 1462 ACPI_STATUS 1463 DtCompileRsdt ( 1464 void **List) 1465 { 1466 DT_SUBTABLE *Subtable; 1467 DT_SUBTABLE *ParentTable; 1468 DT_FIELD *FieldList = *(DT_FIELD **) List; 1469 UINT32 Address; 1470 1471 1472 ParentTable = DtPeekSubtable (); 1473 1474 while (FieldList) 1475 { 1476 DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); 1477 1478 DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); 1479 DtInsertSubtable (ParentTable, Subtable); 1480 FieldList = FieldList->Next; 1481 } 1482 1483 return (AE_OK); 1484 } 1485 1486 1487 /****************************************************************************** 1488 * 1489 * FUNCTION: DtCompileS3pt 1490 * 1491 * PARAMETERS: PFieldList - Current field list pointer 1492 * 1493 * RETURN: Status 1494 * 1495 * DESCRIPTION: Compile S3PT (Pointed to by FPDT) 1496 * 1497 *****************************************************************************/ 1498 1499 ACPI_STATUS 1500 DtCompileS3pt ( 1501 DT_FIELD **PFieldList) 1502 { 1503 ACPI_STATUS Status; 1504 ACPI_FPDT_HEADER *S3ptHeader; 1505 DT_SUBTABLE *Subtable; 1506 DT_SUBTABLE *ParentTable; 1507 ACPI_DMTABLE_INFO *InfoTable; 1508 DT_FIELD *SubtableStart; 1509 1510 1511 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt, 1512 &AslGbl_RootTable); 1513 if (ACPI_FAILURE (Status)) 1514 { 1515 return (Status); 1516 } 1517 1518 DtPushSubtable (AslGbl_RootTable); 1519 1520 while (*PFieldList) 1521 { 1522 SubtableStart = *PFieldList; 1523 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr, 1524 &Subtable); 1525 if (ACPI_FAILURE (Status)) 1526 { 1527 return (Status); 1528 } 1529 1530 ParentTable = DtPeekSubtable (); 1531 DtInsertSubtable (ParentTable, Subtable); 1532 DtPushSubtable (Subtable); 1533 1534 S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); 1535 1536 switch (S3ptHeader->Type) 1537 { 1538 case ACPI_S3PT_TYPE_RESUME: 1539 1540 InfoTable = AcpiDmTableInfoS3pt0; 1541 break; 1542 1543 case ACPI_S3PT_TYPE_SUSPEND: 1544 1545 InfoTable = AcpiDmTableInfoS3pt1; 1546 break; 1547 1548 default: 1549 1550 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); 1551 return (AE_ERROR); 1552 } 1553 1554 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 1555 if (ACPI_FAILURE (Status)) 1556 { 1557 return (Status); 1558 } 1559 1560 ParentTable = DtPeekSubtable (); 1561 DtInsertSubtable (ParentTable, Subtable); 1562 DtPopSubtable (); 1563 } 1564 1565 return (AE_OK); 1566 } 1567 1568 1569 /****************************************************************************** 1570 * 1571 * FUNCTION: DtCompileSdev 1572 * 1573 * PARAMETERS: List - Current field list pointer 1574 * 1575 * RETURN: Status 1576 * 1577 * DESCRIPTION: Compile SDEV. 1578 * 1579 *****************************************************************************/ 1580 1581 ACPI_STATUS 1582 DtCompileSdev ( 1583 void **List) 1584 { 1585 ACPI_STATUS Status; 1586 ACPI_SDEV_HEADER *SdevHeader; 1587 ACPI_SDEV_HEADER *SecureComponentHeader; 1588 DT_SUBTABLE *Subtable; 1589 DT_SUBTABLE *ParentTable; 1590 ACPI_DMTABLE_INFO *InfoTable; 1591 ACPI_DMTABLE_INFO *SecureComponentInfoTable = NULL; 1592 DT_FIELD **PFieldList = (DT_FIELD **) List; 1593 DT_FIELD *SubtableStart; 1594 ACPI_SDEV_PCIE *Pcie = NULL; 1595 ACPI_SDEV_NAMESPACE *Namesp = NULL; 1596 UINT32 EntryCount; 1597 ACPI_SDEV_SECURE_COMPONENT *SecureComponent = NULL; 1598 UINT16 ComponentLength = 0; 1599 1600 1601 /* Subtables */ 1602 1603 while (*PFieldList) 1604 { 1605 /* Compile common SDEV subtable header */ 1606 1607 SubtableStart = *PFieldList; 1608 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevHdr, 1609 &Subtable); 1610 if (ACPI_FAILURE (Status)) 1611 { 1612 return (Status); 1613 } 1614 1615 ParentTable = DtPeekSubtable (); 1616 DtInsertSubtable (ParentTable, Subtable); 1617 DtPushSubtable (Subtable); 1618 1619 SdevHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer); 1620 SdevHeader->Length = (UINT8)(sizeof (ACPI_SDEV_HEADER)); 1621 1622 switch (SdevHeader->Type) 1623 { 1624 case ACPI_SDEV_TYPE_NAMESPACE_DEVICE: 1625 1626 InfoTable = AcpiDmTableInfoSdev0; 1627 Namesp = ACPI_CAST_PTR (ACPI_SDEV_NAMESPACE, Subtable->Buffer); 1628 SecureComponent = ACPI_CAST_PTR (ACPI_SDEV_SECURE_COMPONENT, 1629 ACPI_ADD_PTR (UINT8, Subtable->Buffer, sizeof(ACPI_SDEV_NAMESPACE))); 1630 break; 1631 1632 case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE: 1633 1634 InfoTable = AcpiDmTableInfoSdev1; 1635 Pcie = ACPI_CAST_PTR (ACPI_SDEV_PCIE, Subtable->Buffer); 1636 break; 1637 1638 default: 1639 1640 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV"); 1641 return (AE_ERROR); 1642 } 1643 1644 /* Compile SDEV subtable body */ 1645 1646 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 1647 if (ACPI_FAILURE (Status)) 1648 { 1649 return (Status); 1650 } 1651 1652 ParentTable = DtPeekSubtable (); 1653 DtInsertSubtable (ParentTable, Subtable); 1654 1655 /* Optional data fields are appended to the main subtable body */ 1656 1657 switch (SdevHeader->Type) 1658 { 1659 case ACPI_SDEV_TYPE_NAMESPACE_DEVICE: 1660 1661 /* 1662 * Device Id Offset will be be calculated differently depending on 1663 * the presence of secure access components. 1664 */ 1665 Namesp->DeviceIdOffset = 0; 1666 ComponentLength = 0; 1667 1668 /* If the secure access component exists, get the structures */ 1669 1670 if (SdevHeader->Flags & ACPI_SDEV_SECURE_COMPONENTS_PRESENT) 1671 { 1672 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0b, 1673 &Subtable); 1674 if (ACPI_FAILURE (Status)) 1675 { 1676 return (Status); 1677 } 1678 ParentTable = DtPeekSubtable (); 1679 DtInsertSubtable (ParentTable, Subtable); 1680 1681 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_SECURE_COMPONENT); 1682 1683 /* Compile a secure access component header */ 1684 1685 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevSecCompHdr, 1686 &Subtable); 1687 if (ACPI_FAILURE (Status)) 1688 { 1689 return (Status); 1690 } 1691 ParentTable = DtPeekSubtable (); 1692 DtInsertSubtable (ParentTable, Subtable); 1693 1694 /* Compile the secure access component */ 1695 1696 SecureComponentHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer); 1697 switch (SecureComponentHeader->Type) 1698 { 1699 case ACPI_SDEV_TYPE_ID_COMPONENT: 1700 1701 SecureComponentInfoTable = AcpiDmTableInfoSdevSecCompId; 1702 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_ID_COMPONENT); 1703 ComponentLength = sizeof (ACPI_SDEV_ID_COMPONENT); 1704 break; 1705 1706 case ACPI_SDEV_TYPE_MEM_COMPONENT: 1707 1708 SecureComponentInfoTable = AcpiDmTableInfoSdevSecCompMem; 1709 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_MEM_COMPONENT); 1710 ComponentLength = sizeof (ACPI_SDEV_MEM_COMPONENT); 1711 break; 1712 1713 default: 1714 1715 /* Any other secure component types are undefined */ 1716 1717 return (AE_ERROR); 1718 } 1719 1720 Status = DtCompileTable (PFieldList, SecureComponentInfoTable, 1721 &Subtable); 1722 if (ACPI_FAILURE (Status)) 1723 { 1724 return (Status); 1725 } 1726 ParentTable = DtPeekSubtable (); 1727 DtInsertSubtable (ParentTable, Subtable); 1728 1729 SecureComponent->SecureComponentOffset = 1730 sizeof (ACPI_SDEV_NAMESPACE) + sizeof (ACPI_SDEV_SECURE_COMPONENT); 1731 SecureComponent->SecureComponentLength = ComponentLength; 1732 1733 1734 /* 1735 * Add the secure component to the subtable to be added for the 1736 * the namespace subtable's length 1737 */ 1738 ComponentLength += sizeof (ACPI_SDEV_SECURE_COMPONENT); 1739 } 1740 1741 /* Append DeviceId namespace string */ 1742 1743 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0a, 1744 &Subtable); 1745 if (ACPI_FAILURE (Status)) 1746 { 1747 return (Status); 1748 } 1749 1750 if (!Subtable) 1751 { 1752 break; 1753 } 1754 1755 ParentTable = DtPeekSubtable (); 1756 DtInsertSubtable (ParentTable, Subtable); 1757 1758 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_NAMESPACE); 1759 1760 Namesp->DeviceIdLength = (UINT16) Subtable->Length; 1761 1762 /* Append Vendor data */ 1763 1764 Namesp->VendorDataLength = 0; 1765 Namesp->VendorDataOffset = 0; 1766 1767 if (*PFieldList) 1768 { 1769 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b, 1770 &Subtable); 1771 if (ACPI_FAILURE (Status)) 1772 { 1773 return (Status); 1774 } 1775 1776 if (Subtable) 1777 { 1778 ParentTable = DtPeekSubtable (); 1779 DtInsertSubtable (ParentTable, Subtable); 1780 1781 Namesp->VendorDataOffset = 1782 Namesp->DeviceIdOffset + Namesp->DeviceIdLength; 1783 Namesp->VendorDataLength = 1784 (UINT16) Subtable->Length; 1785 1786 /* Final size of entire namespace structure */ 1787 1788 SdevHeader->Length = (UINT16)(sizeof(ACPI_SDEV_NAMESPACE) + 1789 Subtable->Length + Namesp->DeviceIdLength) + ComponentLength; 1790 } 1791 } 1792 1793 break; 1794 1795 case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE: 1796 1797 /* Append the PCIe path info first */ 1798 1799 EntryCount = 0; 1800 while (*PFieldList && !strcmp ((*PFieldList)->Name, "Device")) 1801 { 1802 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1a, 1803 &Subtable); 1804 if (ACPI_FAILURE (Status)) 1805 { 1806 return (Status); 1807 } 1808 1809 if (!Subtable) 1810 { 1811 DtPopSubtable (); 1812 break; 1813 } 1814 1815 ParentTable = DtPeekSubtable (); 1816 DtInsertSubtable (ParentTable, Subtable); 1817 EntryCount++; 1818 } 1819 1820 /* Path offset will point immediately after the main subtable */ 1821 1822 Pcie->PathOffset = sizeof (ACPI_SDEV_PCIE); 1823 Pcie->PathLength = (UINT16) 1824 (EntryCount * sizeof (ACPI_SDEV_PCIE_PATH)); 1825 1826 /* Append the Vendor Data last */ 1827 1828 Pcie->VendorDataLength = 0; 1829 Pcie->VendorDataOffset = 0; 1830 1831 if (*PFieldList) 1832 { 1833 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b, 1834 &Subtable); 1835 if (ACPI_FAILURE (Status)) 1836 { 1837 return (Status); 1838 } 1839 1840 if (Subtable) 1841 { 1842 ParentTable = DtPeekSubtable (); 1843 DtInsertSubtable (ParentTable, Subtable); 1844 1845 Pcie->VendorDataOffset = 1846 Pcie->PathOffset + Pcie->PathLength; 1847 Pcie->VendorDataLength = (UINT16) 1848 Subtable->Length; 1849 } 1850 } 1851 1852 SdevHeader->Length = 1853 sizeof (ACPI_SDEV_PCIE) + 1854 Pcie->PathLength + Pcie->VendorDataLength; 1855 break; 1856 1857 default: 1858 1859 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV"); 1860 return (AE_ERROR); 1861 } 1862 1863 DtPopSubtable (); 1864 } 1865 1866 return (AE_OK); 1867 } 1868 1869 1870 /****************************************************************************** 1871 * 1872 * FUNCTION: DtCompileSlic 1873 * 1874 * PARAMETERS: List - Current field list pointer 1875 * 1876 * RETURN: Status 1877 * 1878 * DESCRIPTION: Compile SLIC. 1879 * 1880 *****************************************************************************/ 1881 1882 ACPI_STATUS 1883 DtCompileSlic ( 1884 void **List) 1885 { 1886 ACPI_STATUS Status; 1887 DT_SUBTABLE *Subtable; 1888 DT_SUBTABLE *ParentTable; 1889 DT_FIELD **PFieldList = (DT_FIELD **) List; 1890 1891 1892 while (*PFieldList) 1893 { 1894 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, 1895 &Subtable); 1896 if (ACPI_FAILURE (Status)) 1897 { 1898 return (Status); 1899 } 1900 1901 ParentTable = DtPeekSubtable (); 1902 DtInsertSubtable (ParentTable, Subtable); 1903 DtPushSubtable (Subtable); 1904 DtPopSubtable (); 1905 } 1906 1907 return (AE_OK); 1908 } 1909 1910 1911 /****************************************************************************** 1912 * 1913 * FUNCTION: DtCompileSlit 1914 * 1915 * PARAMETERS: List - Current field list pointer 1916 * 1917 * RETURN: Status 1918 * 1919 * DESCRIPTION: Compile SLIT. 1920 * 1921 *****************************************************************************/ 1922 1923 ACPI_STATUS 1924 DtCompileSlit ( 1925 void **List) 1926 { 1927 ACPI_STATUS Status; 1928 DT_SUBTABLE *Subtable; 1929 DT_SUBTABLE *ParentTable; 1930 DT_FIELD **PFieldList = (DT_FIELD **) List; 1931 DT_FIELD *FieldList; 1932 DT_FIELD *EndOfFieldList = NULL; 1933 UINT32 Localities; 1934 UINT32 LocalityListLength; 1935 UINT8 *LocalityBuffer; 1936 1937 1938 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, 1939 &Subtable); 1940 if (ACPI_FAILURE (Status)) 1941 { 1942 return (Status); 1943 } 1944 1945 ParentTable = DtPeekSubtable (); 1946 DtInsertSubtable (ParentTable, Subtable); 1947 1948 Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); 1949 LocalityBuffer = UtLocalCalloc (Localities); 1950 LocalityListLength = 0; 1951 1952 /* Compile each locality buffer */ 1953 1954 FieldList = *PFieldList; 1955 while (FieldList) 1956 { 1957 DtCompileBuffer (LocalityBuffer, 1958 FieldList->Value, FieldList, Localities); 1959 1960 LocalityListLength++; 1961 DtCreateSubtable (LocalityBuffer, Localities, &Subtable); 1962 DtInsertSubtable (ParentTable, Subtable); 1963 EndOfFieldList = FieldList; 1964 FieldList = FieldList->Next; 1965 } 1966 1967 if (LocalityListLength != Localities) 1968 { 1969 sprintf(AslGbl_MsgBuffer, 1970 "Found %u entries, must match LocalityCount: %u", 1971 LocalityListLength, Localities); 1972 DtError (ASL_ERROR, ASL_MSG_ENTRY_LIST, EndOfFieldList, AslGbl_MsgBuffer); 1973 ACPI_FREE (LocalityBuffer); 1974 return (AE_LIMIT); 1975 } 1976 1977 ACPI_FREE (LocalityBuffer); 1978 return (AE_OK); 1979 } 1980 1981 1982 /****************************************************************************** 1983 * 1984 * FUNCTION: DtCompileSrat 1985 * 1986 * PARAMETERS: List - Current field list pointer 1987 * 1988 * RETURN: Status 1989 * 1990 * DESCRIPTION: Compile SRAT. 1991 * 1992 *****************************************************************************/ 1993 1994 ACPI_STATUS 1995 DtCompileSrat ( 1996 void **List) 1997 { 1998 ACPI_STATUS Status; 1999 DT_SUBTABLE *Subtable; 2000 DT_SUBTABLE *ParentTable; 2001 DT_FIELD **PFieldList = (DT_FIELD **) List; 2002 DT_FIELD *SubtableStart; 2003 ACPI_SUBTABLE_HEADER *SratHeader; 2004 ACPI_DMTABLE_INFO *InfoTable; 2005 2006 2007 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, 2008 &Subtable); 2009 if (ACPI_FAILURE (Status)) 2010 { 2011 return (Status); 2012 } 2013 2014 ParentTable = DtPeekSubtable (); 2015 DtInsertSubtable (ParentTable, Subtable); 2016 2017 while (*PFieldList) 2018 { 2019 SubtableStart = *PFieldList; 2020 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, 2021 &Subtable); 2022 if (ACPI_FAILURE (Status)) 2023 { 2024 return (Status); 2025 } 2026 2027 ParentTable = DtPeekSubtable (); 2028 DtInsertSubtable (ParentTable, Subtable); 2029 DtPushSubtable (Subtable); 2030 2031 SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); 2032 2033 switch (SratHeader->Type) 2034 { 2035 case ACPI_SRAT_TYPE_CPU_AFFINITY: 2036 2037 InfoTable = AcpiDmTableInfoSrat0; 2038 break; 2039 2040 case ACPI_SRAT_TYPE_MEMORY_AFFINITY: 2041 2042 InfoTable = AcpiDmTableInfoSrat1; 2043 break; 2044 2045 case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: 2046 2047 InfoTable = AcpiDmTableInfoSrat2; 2048 break; 2049 2050 case ACPI_SRAT_TYPE_GICC_AFFINITY: 2051 2052 InfoTable = AcpiDmTableInfoSrat3; 2053 break; 2054 2055 case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY: 2056 2057 InfoTable = AcpiDmTableInfoSrat4; 2058 break; 2059 2060 case ACPI_SRAT_TYPE_GENERIC_AFFINITY: 2061 2062 InfoTable = AcpiDmTableInfoSrat5; 2063 break; 2064 2065 case ACPI_SRAT_TYPE_GENERIC_PORT_AFFINITY: 2066 2067 InfoTable = AcpiDmTableInfoSrat6; 2068 break; 2069 2070 default: 2071 2072 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); 2073 return (AE_ERROR); 2074 } 2075 2076 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 2077 if (ACPI_FAILURE (Status)) 2078 { 2079 return (Status); 2080 } 2081 2082 ParentTable = DtPeekSubtable (); 2083 DtInsertSubtable (ParentTable, Subtable); 2084 DtPopSubtable (); 2085 } 2086 2087 return (AE_OK); 2088 } 2089 2090 2091 /****************************************************************************** 2092 * 2093 * FUNCTION: DtCompileStao 2094 * 2095 * PARAMETERS: PFieldList - Current field list pointer 2096 * 2097 * RETURN: Status 2098 * 2099 * DESCRIPTION: Compile STAO. 2100 * 2101 *****************************************************************************/ 2102 2103 ACPI_STATUS 2104 DtCompileStao ( 2105 void **List) 2106 { 2107 DT_FIELD **PFieldList = (DT_FIELD **) List; 2108 DT_SUBTABLE *Subtable; 2109 DT_SUBTABLE *ParentTable; 2110 ACPI_STATUS Status; 2111 2112 2113 /* Compile the main table */ 2114 2115 Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao, 2116 &Subtable); 2117 if (ACPI_FAILURE (Status)) 2118 { 2119 return (Status); 2120 } 2121 2122 ParentTable = DtPeekSubtable (); 2123 DtInsertSubtable (ParentTable, Subtable); 2124 2125 /* Compile each ASCII namestring as a subtable */ 2126 2127 while (*PFieldList) 2128 { 2129 Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr, 2130 &Subtable); 2131 if (ACPI_FAILURE (Status)) 2132 { 2133 return (Status); 2134 } 2135 2136 ParentTable = DtPeekSubtable (); 2137 DtInsertSubtable (ParentTable, Subtable); 2138 } 2139 2140 return (AE_OK); 2141 } 2142 2143 2144 2145 /****************************************************************************** 2146 * 2147 * FUNCTION: DtCompileSvkl 2148 * 2149 * PARAMETERS: PFieldList - Current field list pointer 2150 * 2151 * RETURN: Status 2152 * 2153 * DESCRIPTION: Compile SVKL. 2154 * 2155 * NOTES: SVKL is essentially a flat table, with a small main table and 2156 * a variable number of a single type of subtable. 2157 * 2158 *****************************************************************************/ 2159 2160 ACPI_STATUS 2161 DtCompileSvkl ( 2162 void **List) 2163 { 2164 DT_FIELD **PFieldList = (DT_FIELD **) List; 2165 DT_SUBTABLE *Subtable; 2166 DT_SUBTABLE *ParentTable; 2167 ACPI_STATUS Status; 2168 2169 2170 /* Compile the main table */ 2171 2172 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSvkl, 2173 &Subtable); 2174 if (ACPI_FAILURE (Status)) 2175 { 2176 return (Status); 2177 } 2178 2179 ParentTable = DtPeekSubtable (); 2180 DtInsertSubtable (ParentTable, Subtable); 2181 2182 /* Compile each subtable */ 2183 2184 while (*PFieldList) 2185 { 2186 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSvkl0, 2187 &Subtable); 2188 if (ACPI_FAILURE (Status)) 2189 { 2190 return (Status); 2191 } 2192 2193 ParentTable = DtPeekSubtable (); 2194 DtInsertSubtable (ParentTable, Subtable); 2195 } 2196 2197 return (AE_OK); 2198 } 2199 2200 2201 /****************************************************************************** 2202 * 2203 * FUNCTION: DtCompileTcpa 2204 * 2205 * PARAMETERS: PFieldList - Current field list pointer 2206 * 2207 * RETURN: Status 2208 * 2209 * DESCRIPTION: Compile TCPA. 2210 * 2211 *****************************************************************************/ 2212 2213 ACPI_STATUS 2214 DtCompileTcpa ( 2215 void **List) 2216 { 2217 DT_FIELD **PFieldList = (DT_FIELD **) List; 2218 DT_SUBTABLE *Subtable; 2219 ACPI_TABLE_TCPA_HDR *TcpaHeader; 2220 DT_SUBTABLE *ParentTable; 2221 ACPI_STATUS Status; 2222 2223 2224 /* Compile the main table */ 2225 2226 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr, 2227 &Subtable); 2228 if (ACPI_FAILURE (Status)) 2229 { 2230 return (Status); 2231 } 2232 2233 ParentTable = DtPeekSubtable (); 2234 DtInsertSubtable (ParentTable, Subtable); 2235 2236 /* 2237 * Examine the PlatformClass field to determine the table type. 2238 * Either a client or server table. Only one. 2239 */ 2240 TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer); 2241 2242 switch (TcpaHeader->PlatformClass) 2243 { 2244 case ACPI_TCPA_CLIENT_TABLE: 2245 2246 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient, 2247 &Subtable); 2248 break; 2249 2250 case ACPI_TCPA_SERVER_TABLE: 2251 2252 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer, 2253 &Subtable); 2254 break; 2255 2256 default: 2257 2258 AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n", 2259 TcpaHeader->PlatformClass); 2260 Status = AE_ERROR; 2261 break; 2262 } 2263 2264 ParentTable = DtPeekSubtable (); 2265 DtInsertSubtable (ParentTable, Subtable); 2266 return (Status); 2267 } 2268 2269 2270 /****************************************************************************** 2271 * 2272 * FUNCTION: DtCompileTpm2Rev3 2273 * 2274 * PARAMETERS: PFieldList - Current field list pointer 2275 * 2276 * RETURN: Status 2277 * 2278 * DESCRIPTION: Compile TPM2 revision 3 2279 * 2280 *****************************************************************************/ 2281 static ACPI_STATUS 2282 DtCompileTpm2Rev3 ( 2283 void **List) 2284 { 2285 DT_FIELD **PFieldList = (DT_FIELD **) List; 2286 DT_SUBTABLE *Subtable; 2287 ACPI_TABLE_TPM23 *Tpm23Header; 2288 DT_SUBTABLE *ParentTable; 2289 ACPI_STATUS Status = AE_OK; 2290 2291 2292 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm23, 2293 &Subtable); 2294 2295 ParentTable = DtPeekSubtable (); 2296 DtInsertSubtable (ParentTable, Subtable); 2297 Tpm23Header = ACPI_CAST_PTR (ACPI_TABLE_TPM23, ParentTable->Buffer); 2298 2299 /* Subtable type depends on the StartMethod */ 2300 2301 switch (Tpm23Header->StartMethod) 2302 { 2303 case ACPI_TPM23_ACPI_START_METHOD: 2304 2305 /* Subtable specific to to ARM_SMC */ 2306 2307 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm23a, 2308 &Subtable); 2309 if (ACPI_FAILURE (Status)) 2310 { 2311 return (Status); 2312 } 2313 2314 ParentTable = DtPeekSubtable (); 2315 DtInsertSubtable (ParentTable, Subtable); 2316 break; 2317 2318 default: 2319 break; 2320 } 2321 2322 return (Status); 2323 } 2324 2325 2326 /****************************************************************************** 2327 * 2328 * FUNCTION: DtCompileTpm2 2329 * 2330 * PARAMETERS: PFieldList - Current field list pointer 2331 * 2332 * RETURN: Status 2333 * 2334 * DESCRIPTION: Compile TPM2. 2335 * 2336 *****************************************************************************/ 2337 2338 ACPI_STATUS 2339 DtCompileTpm2 ( 2340 void **List) 2341 { 2342 DT_FIELD **PFieldList = (DT_FIELD **) List; 2343 DT_SUBTABLE *Subtable; 2344 ACPI_TABLE_TPM2 *Tpm2Header; 2345 DT_SUBTABLE *ParentTable; 2346 ACPI_STATUS Status = AE_OK; 2347 ACPI_TABLE_HEADER *Header; 2348 2349 2350 ParentTable = DtPeekSubtable (); 2351 2352 Header = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); 2353 2354 if (Header->Revision == 3) 2355 { 2356 return (DtCompileTpm2Rev3 (List)); 2357 } 2358 2359 /* Compile the main table */ 2360 2361 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2, 2362 &Subtable); 2363 if (ACPI_FAILURE (Status)) 2364 { 2365 return (Status); 2366 } 2367 2368 ParentTable = DtPeekSubtable (); 2369 DtInsertSubtable (ParentTable, Subtable); 2370 2371 Tpm2Header = ACPI_CAST_PTR (ACPI_TABLE_TPM2, ParentTable->Buffer); 2372 2373 /* Method parameters */ 2374 /* Optional: Log area minimum length */ 2375 /* Optional: Log area start address */ 2376 /* TBD: Optional fields above not fully implemented (not optional at this time) */ 2377 2378 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2a, 2379 &Subtable); 2380 if (ACPI_FAILURE (Status)) 2381 { 2382 return (Status); 2383 } 2384 2385 ParentTable = DtPeekSubtable (); 2386 DtInsertSubtable (ParentTable, Subtable); 2387 2388 2389 /* Subtable type depends on the StartMethod */ 2390 2391 switch (Tpm2Header->StartMethod) 2392 { 2393 case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC: 2394 2395 /* Subtable specific to to ARM_SMC */ 2396 2397 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm211, 2398 &Subtable); 2399 if (ACPI_FAILURE (Status)) 2400 { 2401 return (Status); 2402 } 2403 2404 ParentTable = DtPeekSubtable (); 2405 DtInsertSubtable (ParentTable, Subtable); 2406 break; 2407 2408 case ACPI_TPM2_START_METHOD: 2409 case ACPI_TPM2_MEMORY_MAPPED: 2410 case ACPI_TPM2_COMMAND_BUFFER: 2411 case ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD: 2412 break; 2413 2414 case ACPI_TPM2_RESERVED1: 2415 case ACPI_TPM2_RESERVED3: 2416 case ACPI_TPM2_RESERVED4: 2417 case ACPI_TPM2_RESERVED5: 2418 case ACPI_TPM2_RESERVED9: 2419 case ACPI_TPM2_RESERVED10: 2420 2421 AcpiOsPrintf ("\n**** Reserved TPM2 Start Method type 0x%X\n", 2422 Tpm2Header->StartMethod); 2423 Status = AE_ERROR; 2424 break; 2425 2426 case ACPI_TPM2_NOT_ALLOWED: 2427 default: 2428 2429 AcpiOsPrintf ("\n**** Unknown TPM2 Start Method type 0x%X\n", 2430 Tpm2Header->StartMethod); 2431 Status = AE_ERROR; 2432 break; 2433 } 2434 2435 return (Status); 2436 } 2437 2438 2439 /****************************************************************************** 2440 * 2441 * FUNCTION: DtGetGenericTableInfo 2442 * 2443 * PARAMETERS: Name - Generic type name 2444 * 2445 * RETURN: Info entry 2446 * 2447 * DESCRIPTION: Obtain table info for a generic name entry 2448 * 2449 *****************************************************************************/ 2450 2451 ACPI_DMTABLE_INFO * 2452 DtGetGenericTableInfo ( 2453 char *Name) 2454 { 2455 ACPI_DMTABLE_INFO *Info; 2456 UINT32 i; 2457 2458 2459 if (!Name) 2460 { 2461 return (NULL); 2462 } 2463 2464 /* Search info table for name match */ 2465 2466 for (i = 0; ; i++) 2467 { 2468 Info = AcpiDmTableInfoGeneric[i]; 2469 if (Info->Opcode == ACPI_DMT_EXIT) 2470 { 2471 Info = NULL; 2472 break; 2473 } 2474 2475 /* Use caseless compare for generic keywords */ 2476 2477 if (!AcpiUtStricmp (Name, Info->Name)) 2478 { 2479 break; 2480 } 2481 } 2482 2483 return (Info); 2484 } 2485 2486 2487 /****************************************************************************** 2488 * 2489 * FUNCTION: DtCompileUefi 2490 * 2491 * PARAMETERS: List - Current field list pointer 2492 * 2493 * RETURN: Status 2494 * 2495 * DESCRIPTION: Compile UEFI. 2496 * 2497 *****************************************************************************/ 2498 2499 ACPI_STATUS 2500 DtCompileUefi ( 2501 void **List) 2502 { 2503 ACPI_STATUS Status; 2504 DT_SUBTABLE *Subtable; 2505 DT_SUBTABLE *ParentTable; 2506 DT_FIELD **PFieldList = (DT_FIELD **) List; 2507 UINT16 *DataOffset; 2508 2509 2510 /* Compile the predefined portion of the UEFI table */ 2511 2512 Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, 2513 &Subtable); 2514 if (ACPI_FAILURE (Status)) 2515 { 2516 return (Status); 2517 } 2518 2519 DataOffset = (UINT16 *) (Subtable->Buffer + 16); 2520 *DataOffset = sizeof (ACPI_TABLE_UEFI); 2521 2522 ParentTable = DtPeekSubtable (); 2523 DtInsertSubtable (ParentTable, Subtable); 2524 2525 /* 2526 * Compile the "generic" portion of the UEFI table. This 2527 * part of the table is not predefined and any of the generic 2528 * operators may be used. 2529 */ 2530 DtCompileGeneric ((void **) PFieldList, NULL, NULL); 2531 return (AE_OK); 2532 } 2533 2534 2535 /****************************************************************************** 2536 * 2537 * FUNCTION: DtCompileViot 2538 * 2539 * PARAMETERS: List - Current field list pointer 2540 * 2541 * RETURN: Status 2542 * 2543 * DESCRIPTION: Compile VIOT. 2544 * 2545 *****************************************************************************/ 2546 2547 ACPI_STATUS 2548 DtCompileViot ( 2549 void **List) 2550 { 2551 ACPI_STATUS Status; 2552 DT_SUBTABLE *Subtable; 2553 DT_SUBTABLE *ParentTable; 2554 DT_FIELD **PFieldList = (DT_FIELD **) List; 2555 DT_FIELD *SubtableStart; 2556 ACPI_TABLE_VIOT *Viot; 2557 ACPI_VIOT_HEADER *ViotHeader; 2558 ACPI_DMTABLE_INFO *InfoTable; 2559 UINT16 NodeCount; 2560 2561 ParentTable = DtPeekSubtable (); 2562 2563 Status = DtCompileTable (PFieldList, AcpiDmTableInfoViot, &Subtable); 2564 if (ACPI_FAILURE (Status)) 2565 { 2566 return (Status); 2567 } 2568 DtInsertSubtable (ParentTable, Subtable); 2569 2570 /* 2571 * Using ACPI_SUB_PTR, We needn't define a separate structure. Care 2572 * should be taken to avoid accessing ACPI_TABLE_HEADER fields. 2573 */ 2574 Viot = ACPI_SUB_PTR (ACPI_TABLE_VIOT, Subtable->Buffer, 2575 sizeof (ACPI_TABLE_HEADER)); 2576 2577 Viot->NodeOffset = sizeof (ACPI_TABLE_VIOT); 2578 2579 NodeCount = 0; 2580 while (*PFieldList) { 2581 SubtableStart = *PFieldList; 2582 Status = DtCompileTable (PFieldList, AcpiDmTableInfoViotHeader, 2583 &Subtable); 2584 if (ACPI_FAILURE (Status)) 2585 { 2586 return (Status); 2587 } 2588 2589 ParentTable = DtPeekSubtable (); 2590 DtInsertSubtable (ParentTable, Subtable); 2591 DtPushSubtable (Subtable); 2592 2593 ViotHeader = ACPI_CAST_PTR (ACPI_VIOT_HEADER, Subtable->Buffer); 2594 2595 switch (ViotHeader->Type) 2596 { 2597 case ACPI_VIOT_NODE_PCI_RANGE: 2598 2599 InfoTable = AcpiDmTableInfoViot1; 2600 break; 2601 2602 case ACPI_VIOT_NODE_MMIO: 2603 2604 InfoTable = AcpiDmTableInfoViot2; 2605 break; 2606 2607 case ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI: 2608 2609 InfoTable = AcpiDmTableInfoViot3; 2610 break; 2611 2612 case ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO: 2613 2614 InfoTable = AcpiDmTableInfoViot4; 2615 break; 2616 2617 default: 2618 2619 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "VIOT"); 2620 return (AE_ERROR); 2621 } 2622 2623 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 2624 if (ACPI_FAILURE (Status)) 2625 { 2626 return (Status); 2627 } 2628 2629 ParentTable = DtPeekSubtable (); 2630 DtInsertSubtable (ParentTable, Subtable); 2631 DtPopSubtable (); 2632 NodeCount++; 2633 } 2634 2635 Viot->NodeCount = NodeCount; 2636 return (AE_OK); 2637 } 2638 2639 2640 /****************************************************************************** 2641 * 2642 * FUNCTION: DtCompileWdat 2643 * 2644 * PARAMETERS: List - Current field list pointer 2645 * 2646 * RETURN: Status 2647 * 2648 * DESCRIPTION: Compile WDAT. 2649 * 2650 *****************************************************************************/ 2651 2652 ACPI_STATUS 2653 DtCompileWdat ( 2654 void **List) 2655 { 2656 ACPI_STATUS Status; 2657 2658 2659 Status = DtCompileTwoSubtables (List, 2660 AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); 2661 return (Status); 2662 } 2663 2664 2665 /****************************************************************************** 2666 * 2667 * FUNCTION: DtCompileWpbt 2668 * 2669 * PARAMETERS: List - Current field list pointer 2670 * 2671 * RETURN: Status 2672 * 2673 * DESCRIPTION: Compile WPBT. 2674 * 2675 *****************************************************************************/ 2676 2677 ACPI_STATUS 2678 DtCompileWpbt ( 2679 void **List) 2680 { 2681 DT_FIELD **PFieldList = (DT_FIELD **) List; 2682 DT_SUBTABLE *Subtable; 2683 DT_SUBTABLE *ParentTable; 2684 ACPI_TABLE_WPBT *Table; 2685 ACPI_STATUS Status; 2686 2687 2688 /* Compile the main table */ 2689 2690 Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, &Subtable); 2691 if (ACPI_FAILURE (Status)) 2692 { 2693 return (Status); 2694 } 2695 2696 ParentTable = DtPeekSubtable (); 2697 DtInsertSubtable (ParentTable, Subtable); 2698 Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer); 2699 2700 /* 2701 * Exit now if there are no arguments specified. This is indicated by: 2702 * The "Command-line Arguments" field has not been specified (if specified, 2703 * it will be the last field in the field list -- after the main table). 2704 * Set the Argument Length in the main table to zero. 2705 */ 2706 if (!*PFieldList) 2707 { 2708 Table->ArgumentsLength = 0; 2709 return (AE_OK); 2710 } 2711 2712 /* Compile the argument list subtable */ 2713 2714 Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, &Subtable); 2715 if (ACPI_FAILURE (Status)) 2716 { 2717 return (Status); 2718 } 2719 2720 /* Extract the length of the Arguments buffer, insert into main table */ 2721 2722 Table->ArgumentsLength = (UINT16) Subtable->TotalLength; 2723 DtInsertSubtable (ParentTable, Subtable); 2724 return (AE_OK); 2725 } 2726 2727 2728 /****************************************************************************** 2729 * 2730 * FUNCTION: DtCompileXsdt 2731 * 2732 * PARAMETERS: List - Current field list pointer 2733 * 2734 * RETURN: Status 2735 * 2736 * DESCRIPTION: Compile XSDT. 2737 * 2738 *****************************************************************************/ 2739 2740 ACPI_STATUS 2741 DtCompileXsdt ( 2742 void **List) 2743 { 2744 DT_SUBTABLE *Subtable; 2745 DT_SUBTABLE *ParentTable; 2746 DT_FIELD *FieldList = *(DT_FIELD **) List; 2747 UINT64 Address; 2748 2749 2750 ParentTable = DtPeekSubtable (); 2751 2752 while (FieldList) 2753 { 2754 DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); 2755 2756 DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); 2757 DtInsertSubtable (ParentTable, Subtable); 2758 FieldList = FieldList->Next; 2759 } 2760 2761 return (AE_OK); 2762 } 2763 2764 2765 /****************************************************************************** 2766 * 2767 * FUNCTION: DtCompileGeneric 2768 * 2769 * PARAMETERS: List - Current field list pointer 2770 * Name - Field name to end generic compiling 2771 * Length - Compiled table length to return 2772 * 2773 * RETURN: Status 2774 * 2775 * DESCRIPTION: Compile generic unknown table. 2776 * 2777 *****************************************************************************/ 2778 2779 ACPI_STATUS 2780 DtCompileGeneric ( 2781 void **List, 2782 char *Name, 2783 UINT32 *Length) 2784 { 2785 ACPI_STATUS Status; 2786 DT_SUBTABLE *Subtable; 2787 DT_SUBTABLE *ParentTable; 2788 DT_FIELD **PFieldList = (DT_FIELD **) List; 2789 ACPI_DMTABLE_INFO *Info; 2790 2791 2792 ParentTable = DtPeekSubtable (); 2793 2794 /* 2795 * Compile the "generic" portion of the table. This 2796 * part of the table is not predefined and any of the generic 2797 * operators may be used. 2798 */ 2799 2800 /* Find any and all labels in the entire generic portion */ 2801 2802 DtDetectAllLabels (*PFieldList); 2803 2804 /* Now we can actually compile the parse tree */ 2805 2806 if (Length && *Length) 2807 { 2808 *Length = 0; 2809 } 2810 while (*PFieldList) 2811 { 2812 if (Name && !strcmp ((*PFieldList)->Name, Name)) 2813 { 2814 break; 2815 } 2816 2817 Info = DtGetGenericTableInfo ((*PFieldList)->Name); 2818 if (!Info) 2819 { 2820 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found", 2821 (*PFieldList)->Name); 2822 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, 2823 (*PFieldList), AslGbl_MsgBuffer); 2824 2825 *PFieldList = (*PFieldList)->Next; 2826 continue; 2827 } 2828 2829 Status = DtCompileTable (PFieldList, Info, 2830 &Subtable); 2831 if (ACPI_SUCCESS (Status)) 2832 { 2833 DtInsertSubtable (ParentTable, Subtable); 2834 if (Length) 2835 { 2836 *Length += Subtable->Length; 2837 } 2838 } 2839 else 2840 { 2841 *PFieldList = (*PFieldList)->Next; 2842 2843 if (Status == AE_NOT_FOUND) 2844 { 2845 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found", 2846 (*PFieldList)->Name); 2847 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, 2848 (*PFieldList), AslGbl_MsgBuffer); 2849 } 2850 } 2851 } 2852 2853 return (AE_OK); 2854 } 2855