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: DtCompileRsdt 1341 * 1342 * PARAMETERS: List - Current field list pointer 1343 * 1344 * RETURN: Status 1345 * 1346 * DESCRIPTION: Compile RSDT. 1347 * 1348 *****************************************************************************/ 1349 1350 ACPI_STATUS 1351 DtCompileRsdt ( 1352 void **List) 1353 { 1354 DT_SUBTABLE *Subtable; 1355 DT_SUBTABLE *ParentTable; 1356 DT_FIELD *FieldList = *(DT_FIELD **) List; 1357 UINT32 Address; 1358 1359 1360 ParentTable = DtPeekSubtable (); 1361 1362 while (FieldList) 1363 { 1364 DtCompileInteger ((UINT8 *) &Address, FieldList, 4, DT_NON_ZERO); 1365 1366 DtCreateSubtable ((UINT8 *) &Address, 4, &Subtable); 1367 DtInsertSubtable (ParentTable, Subtable); 1368 FieldList = FieldList->Next; 1369 } 1370 1371 return (AE_OK); 1372 } 1373 1374 1375 /****************************************************************************** 1376 * 1377 * FUNCTION: DtCompileS3pt 1378 * 1379 * PARAMETERS: PFieldList - Current field list pointer 1380 * 1381 * RETURN: Status 1382 * 1383 * DESCRIPTION: Compile S3PT (Pointed to by FPDT) 1384 * 1385 *****************************************************************************/ 1386 1387 ACPI_STATUS 1388 DtCompileS3pt ( 1389 DT_FIELD **PFieldList) 1390 { 1391 ACPI_STATUS Status; 1392 ACPI_FPDT_HEADER *S3ptHeader; 1393 DT_SUBTABLE *Subtable; 1394 DT_SUBTABLE *ParentTable; 1395 ACPI_DMTABLE_INFO *InfoTable; 1396 DT_FIELD *SubtableStart; 1397 1398 1399 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt, 1400 &AslGbl_RootTable); 1401 if (ACPI_FAILURE (Status)) 1402 { 1403 return (Status); 1404 } 1405 1406 DtPushSubtable (AslGbl_RootTable); 1407 1408 while (*PFieldList) 1409 { 1410 SubtableStart = *PFieldList; 1411 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3ptHdr, 1412 &Subtable); 1413 if (ACPI_FAILURE (Status)) 1414 { 1415 return (Status); 1416 } 1417 1418 ParentTable = DtPeekSubtable (); 1419 DtInsertSubtable (ParentTable, Subtable); 1420 DtPushSubtable (Subtable); 1421 1422 S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); 1423 1424 switch (S3ptHeader->Type) 1425 { 1426 case ACPI_S3PT_TYPE_RESUME: 1427 1428 InfoTable = AcpiDmTableInfoS3pt0; 1429 break; 1430 1431 case ACPI_S3PT_TYPE_SUSPEND: 1432 1433 InfoTable = AcpiDmTableInfoS3pt1; 1434 break; 1435 1436 default: 1437 1438 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); 1439 return (AE_ERROR); 1440 } 1441 1442 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 1443 if (ACPI_FAILURE (Status)) 1444 { 1445 return (Status); 1446 } 1447 1448 ParentTable = DtPeekSubtable (); 1449 DtInsertSubtable (ParentTable, Subtable); 1450 DtPopSubtable (); 1451 } 1452 1453 return (AE_OK); 1454 } 1455 1456 1457 /****************************************************************************** 1458 * 1459 * FUNCTION: DtCompileSdev 1460 * 1461 * PARAMETERS: List - Current field list pointer 1462 * 1463 * RETURN: Status 1464 * 1465 * DESCRIPTION: Compile SDEV. 1466 * 1467 *****************************************************************************/ 1468 1469 ACPI_STATUS 1470 DtCompileSdev ( 1471 void **List) 1472 { 1473 ACPI_STATUS Status; 1474 ACPI_SDEV_HEADER *SdevHeader; 1475 ACPI_SDEV_HEADER *SecureComponentHeader; 1476 DT_SUBTABLE *Subtable; 1477 DT_SUBTABLE *ParentTable; 1478 ACPI_DMTABLE_INFO *InfoTable; 1479 ACPI_DMTABLE_INFO *SecureComponentInfoTable = NULL; 1480 DT_FIELD **PFieldList = (DT_FIELD **) List; 1481 DT_FIELD *SubtableStart; 1482 ACPI_SDEV_PCIE *Pcie = NULL; 1483 ACPI_SDEV_NAMESPACE *Namesp = NULL; 1484 UINT32 EntryCount; 1485 ACPI_SDEV_SECURE_COMPONENT *SecureComponent = NULL; 1486 UINT16 ComponentLength = 0; 1487 1488 1489 /* Subtables */ 1490 1491 while (*PFieldList) 1492 { 1493 /* Compile common SDEV subtable header */ 1494 1495 SubtableStart = *PFieldList; 1496 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevHdr, 1497 &Subtable); 1498 if (ACPI_FAILURE (Status)) 1499 { 1500 return (Status); 1501 } 1502 1503 ParentTable = DtPeekSubtable (); 1504 DtInsertSubtable (ParentTable, Subtable); 1505 DtPushSubtable (Subtable); 1506 1507 SdevHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer); 1508 SdevHeader->Length = (UINT8)(sizeof (ACPI_SDEV_HEADER)); 1509 1510 switch (SdevHeader->Type) 1511 { 1512 case ACPI_SDEV_TYPE_NAMESPACE_DEVICE: 1513 1514 InfoTable = AcpiDmTableInfoSdev0; 1515 Namesp = ACPI_CAST_PTR (ACPI_SDEV_NAMESPACE, Subtable->Buffer); 1516 SecureComponent = ACPI_CAST_PTR (ACPI_SDEV_SECURE_COMPONENT, 1517 ACPI_ADD_PTR (UINT8, Subtable->Buffer, sizeof(ACPI_SDEV_NAMESPACE))); 1518 break; 1519 1520 case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE: 1521 1522 InfoTable = AcpiDmTableInfoSdev1; 1523 Pcie = ACPI_CAST_PTR (ACPI_SDEV_PCIE, Subtable->Buffer); 1524 break; 1525 1526 default: 1527 1528 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV"); 1529 return (AE_ERROR); 1530 } 1531 1532 /* Compile SDEV subtable body */ 1533 1534 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 1535 if (ACPI_FAILURE (Status)) 1536 { 1537 return (Status); 1538 } 1539 1540 ParentTable = DtPeekSubtable (); 1541 DtInsertSubtable (ParentTable, Subtable); 1542 1543 /* Optional data fields are appended to the main subtable body */ 1544 1545 switch (SdevHeader->Type) 1546 { 1547 case ACPI_SDEV_TYPE_NAMESPACE_DEVICE: 1548 1549 /* 1550 * Device Id Offset will be be calculated differently depending on 1551 * the presence of secure access components. 1552 */ 1553 Namesp->DeviceIdOffset = 0; 1554 ComponentLength = 0; 1555 1556 /* If the secure access component exists, get the structures */ 1557 1558 if (SdevHeader->Flags & ACPI_SDEV_SECURE_COMPONENTS_PRESENT) 1559 { 1560 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0b, 1561 &Subtable); 1562 if (ACPI_FAILURE (Status)) 1563 { 1564 return (Status); 1565 } 1566 ParentTable = DtPeekSubtable (); 1567 DtInsertSubtable (ParentTable, Subtable); 1568 1569 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_SECURE_COMPONENT); 1570 1571 /* Compile a secure access component header */ 1572 1573 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdevSecCompHdr, 1574 &Subtable); 1575 if (ACPI_FAILURE (Status)) 1576 { 1577 return (Status); 1578 } 1579 ParentTable = DtPeekSubtable (); 1580 DtInsertSubtable (ParentTable, Subtable); 1581 1582 /* Compile the secure access component */ 1583 1584 SecureComponentHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer); 1585 switch (SecureComponentHeader->Type) 1586 { 1587 case ACPI_SDEV_TYPE_ID_COMPONENT: 1588 1589 SecureComponentInfoTable = AcpiDmTableInfoSdevSecCompId; 1590 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_ID_COMPONENT); 1591 ComponentLength = sizeof (ACPI_SDEV_ID_COMPONENT); 1592 break; 1593 1594 case ACPI_SDEV_TYPE_MEM_COMPONENT: 1595 1596 SecureComponentInfoTable = AcpiDmTableInfoSdevSecCompMem; 1597 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_MEM_COMPONENT); 1598 ComponentLength = sizeof (ACPI_SDEV_MEM_COMPONENT); 1599 break; 1600 1601 default: 1602 1603 /* Any other secure component types are undefined */ 1604 1605 return (AE_ERROR); 1606 } 1607 1608 Status = DtCompileTable (PFieldList, SecureComponentInfoTable, 1609 &Subtable); 1610 if (ACPI_FAILURE (Status)) 1611 { 1612 return (Status); 1613 } 1614 ParentTable = DtPeekSubtable (); 1615 DtInsertSubtable (ParentTable, Subtable); 1616 1617 SecureComponent->SecureComponentOffset = 1618 sizeof (ACPI_SDEV_NAMESPACE) + sizeof (ACPI_SDEV_SECURE_COMPONENT); 1619 SecureComponent->SecureComponentLength = ComponentLength; 1620 1621 1622 /* 1623 * Add the secure component to the subtable to be added for the 1624 * the namespace subtable's length 1625 */ 1626 ComponentLength += sizeof (ACPI_SDEV_SECURE_COMPONENT); 1627 } 1628 1629 /* Append DeviceId namespace string */ 1630 1631 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev0a, 1632 &Subtable); 1633 if (ACPI_FAILURE (Status)) 1634 { 1635 return (Status); 1636 } 1637 1638 if (!Subtable) 1639 { 1640 break; 1641 } 1642 1643 ParentTable = DtPeekSubtable (); 1644 DtInsertSubtable (ParentTable, Subtable); 1645 1646 Namesp->DeviceIdOffset += sizeof (ACPI_SDEV_NAMESPACE); 1647 1648 Namesp->DeviceIdLength = (UINT16) Subtable->Length; 1649 1650 /* Append Vendor data */ 1651 1652 Namesp->VendorDataLength = 0; 1653 Namesp->VendorDataOffset = 0; 1654 1655 if (*PFieldList) 1656 { 1657 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b, 1658 &Subtable); 1659 if (ACPI_FAILURE (Status)) 1660 { 1661 return (Status); 1662 } 1663 1664 if (Subtable) 1665 { 1666 ParentTable = DtPeekSubtable (); 1667 DtInsertSubtable (ParentTable, Subtable); 1668 1669 Namesp->VendorDataOffset = 1670 Namesp->DeviceIdOffset + Namesp->DeviceIdLength; 1671 Namesp->VendorDataLength = 1672 (UINT16) Subtable->Length; 1673 1674 /* Final size of entire namespace structure */ 1675 1676 SdevHeader->Length = (UINT16)(sizeof(ACPI_SDEV_NAMESPACE) + 1677 Subtable->Length + Namesp->DeviceIdLength) + ComponentLength; 1678 } 1679 } 1680 1681 break; 1682 1683 case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE: 1684 1685 /* Append the PCIe path info first */ 1686 1687 EntryCount = 0; 1688 while (*PFieldList && !strcmp ((*PFieldList)->Name, "Device")) 1689 { 1690 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1a, 1691 &Subtable); 1692 if (ACPI_FAILURE (Status)) 1693 { 1694 return (Status); 1695 } 1696 1697 if (!Subtable) 1698 { 1699 DtPopSubtable (); 1700 break; 1701 } 1702 1703 ParentTable = DtPeekSubtable (); 1704 DtInsertSubtable (ParentTable, Subtable); 1705 EntryCount++; 1706 } 1707 1708 /* Path offset will point immediately after the main subtable */ 1709 1710 Pcie->PathOffset = sizeof (ACPI_SDEV_PCIE); 1711 Pcie->PathLength = (UINT16) 1712 (EntryCount * sizeof (ACPI_SDEV_PCIE_PATH)); 1713 1714 /* Append the Vendor Data last */ 1715 1716 Pcie->VendorDataLength = 0; 1717 Pcie->VendorDataOffset = 0; 1718 1719 if (*PFieldList) 1720 { 1721 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSdev1b, 1722 &Subtable); 1723 if (ACPI_FAILURE (Status)) 1724 { 1725 return (Status); 1726 } 1727 1728 if (Subtable) 1729 { 1730 ParentTable = DtPeekSubtable (); 1731 DtInsertSubtable (ParentTable, Subtable); 1732 1733 Pcie->VendorDataOffset = 1734 Pcie->PathOffset + Pcie->PathLength; 1735 Pcie->VendorDataLength = (UINT16) 1736 Subtable->Length; 1737 } 1738 } 1739 1740 SdevHeader->Length = 1741 sizeof (ACPI_SDEV_PCIE) + 1742 Pcie->PathLength + Pcie->VendorDataLength; 1743 break; 1744 1745 default: 1746 1747 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SDEV"); 1748 return (AE_ERROR); 1749 } 1750 1751 DtPopSubtable (); 1752 } 1753 1754 return (AE_OK); 1755 } 1756 1757 1758 /****************************************************************************** 1759 * 1760 * FUNCTION: DtCompileSlic 1761 * 1762 * PARAMETERS: List - Current field list pointer 1763 * 1764 * RETURN: Status 1765 * 1766 * DESCRIPTION: Compile SLIC. 1767 * 1768 *****************************************************************************/ 1769 1770 ACPI_STATUS 1771 DtCompileSlic ( 1772 void **List) 1773 { 1774 ACPI_STATUS Status; 1775 DT_SUBTABLE *Subtable; 1776 DT_SUBTABLE *ParentTable; 1777 DT_FIELD **PFieldList = (DT_FIELD **) List; 1778 1779 1780 while (*PFieldList) 1781 { 1782 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, 1783 &Subtable); 1784 if (ACPI_FAILURE (Status)) 1785 { 1786 return (Status); 1787 } 1788 1789 ParentTable = DtPeekSubtable (); 1790 DtInsertSubtable (ParentTable, Subtable); 1791 DtPushSubtable (Subtable); 1792 DtPopSubtable (); 1793 } 1794 1795 return (AE_OK); 1796 } 1797 1798 1799 /****************************************************************************** 1800 * 1801 * FUNCTION: DtCompileSlit 1802 * 1803 * PARAMETERS: List - Current field list pointer 1804 * 1805 * RETURN: Status 1806 * 1807 * DESCRIPTION: Compile SLIT. 1808 * 1809 *****************************************************************************/ 1810 1811 ACPI_STATUS 1812 DtCompileSlit ( 1813 void **List) 1814 { 1815 ACPI_STATUS Status; 1816 DT_SUBTABLE *Subtable; 1817 DT_SUBTABLE *ParentTable; 1818 DT_FIELD **PFieldList = (DT_FIELD **) List; 1819 DT_FIELD *FieldList; 1820 DT_FIELD *EndOfFieldList = NULL; 1821 UINT32 Localities; 1822 UINT32 LocalityListLength; 1823 UINT8 *LocalityBuffer; 1824 1825 1826 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit, 1827 &Subtable); 1828 if (ACPI_FAILURE (Status)) 1829 { 1830 return (Status); 1831 } 1832 1833 ParentTable = DtPeekSubtable (); 1834 DtInsertSubtable (ParentTable, Subtable); 1835 1836 Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); 1837 LocalityBuffer = UtLocalCalloc (Localities); 1838 LocalityListLength = 0; 1839 1840 /* Compile each locality buffer */ 1841 1842 FieldList = *PFieldList; 1843 while (FieldList) 1844 { 1845 DtCompileBuffer (LocalityBuffer, 1846 FieldList->Value, FieldList, Localities); 1847 1848 LocalityListLength++; 1849 DtCreateSubtable (LocalityBuffer, Localities, &Subtable); 1850 DtInsertSubtable (ParentTable, Subtable); 1851 EndOfFieldList = FieldList; 1852 FieldList = FieldList->Next; 1853 } 1854 1855 if (LocalityListLength != Localities) 1856 { 1857 sprintf(AslGbl_MsgBuffer, 1858 "Found %u entries, must match LocalityCount: %u", 1859 LocalityListLength, Localities); 1860 DtError (ASL_ERROR, ASL_MSG_ENTRY_LIST, EndOfFieldList, AslGbl_MsgBuffer); 1861 ACPI_FREE (LocalityBuffer); 1862 return (AE_LIMIT); 1863 } 1864 1865 ACPI_FREE (LocalityBuffer); 1866 return (AE_OK); 1867 } 1868 1869 1870 /****************************************************************************** 1871 * 1872 * FUNCTION: DtCompileSrat 1873 * 1874 * PARAMETERS: List - Current field list pointer 1875 * 1876 * RETURN: Status 1877 * 1878 * DESCRIPTION: Compile SRAT. 1879 * 1880 *****************************************************************************/ 1881 1882 ACPI_STATUS 1883 DtCompileSrat ( 1884 void **List) 1885 { 1886 ACPI_STATUS Status; 1887 DT_SUBTABLE *Subtable; 1888 DT_SUBTABLE *ParentTable; 1889 DT_FIELD **PFieldList = (DT_FIELD **) List; 1890 DT_FIELD *SubtableStart; 1891 ACPI_SUBTABLE_HEADER *SratHeader; 1892 ACPI_DMTABLE_INFO *InfoTable; 1893 1894 1895 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSrat, 1896 &Subtable); 1897 if (ACPI_FAILURE (Status)) 1898 { 1899 return (Status); 1900 } 1901 1902 ParentTable = DtPeekSubtable (); 1903 DtInsertSubtable (ParentTable, Subtable); 1904 1905 while (*PFieldList) 1906 { 1907 SubtableStart = *PFieldList; 1908 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSratHdr, 1909 &Subtable); 1910 if (ACPI_FAILURE (Status)) 1911 { 1912 return (Status); 1913 } 1914 1915 ParentTable = DtPeekSubtable (); 1916 DtInsertSubtable (ParentTable, Subtable); 1917 DtPushSubtable (Subtable); 1918 1919 SratHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); 1920 1921 switch (SratHeader->Type) 1922 { 1923 case ACPI_SRAT_TYPE_CPU_AFFINITY: 1924 1925 InfoTable = AcpiDmTableInfoSrat0; 1926 break; 1927 1928 case ACPI_SRAT_TYPE_MEMORY_AFFINITY: 1929 1930 InfoTable = AcpiDmTableInfoSrat1; 1931 break; 1932 1933 case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: 1934 1935 InfoTable = AcpiDmTableInfoSrat2; 1936 break; 1937 1938 case ACPI_SRAT_TYPE_GICC_AFFINITY: 1939 1940 InfoTable = AcpiDmTableInfoSrat3; 1941 break; 1942 1943 case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY: 1944 1945 InfoTable = AcpiDmTableInfoSrat4; 1946 break; 1947 1948 case ACPI_SRAT_TYPE_GENERIC_AFFINITY: 1949 1950 InfoTable = AcpiDmTableInfoSrat5; 1951 break; 1952 1953 default: 1954 1955 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); 1956 return (AE_ERROR); 1957 } 1958 1959 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 1960 if (ACPI_FAILURE (Status)) 1961 { 1962 return (Status); 1963 } 1964 1965 ParentTable = DtPeekSubtable (); 1966 DtInsertSubtable (ParentTable, Subtable); 1967 DtPopSubtable (); 1968 } 1969 1970 return (AE_OK); 1971 } 1972 1973 1974 /****************************************************************************** 1975 * 1976 * FUNCTION: DtCompileStao 1977 * 1978 * PARAMETERS: PFieldList - Current field list pointer 1979 * 1980 * RETURN: Status 1981 * 1982 * DESCRIPTION: Compile STAO. 1983 * 1984 *****************************************************************************/ 1985 1986 ACPI_STATUS 1987 DtCompileStao ( 1988 void **List) 1989 { 1990 DT_FIELD **PFieldList = (DT_FIELD **) List; 1991 DT_SUBTABLE *Subtable; 1992 DT_SUBTABLE *ParentTable; 1993 ACPI_STATUS Status; 1994 1995 1996 /* Compile the main table */ 1997 1998 Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao, 1999 &Subtable); 2000 if (ACPI_FAILURE (Status)) 2001 { 2002 return (Status); 2003 } 2004 2005 ParentTable = DtPeekSubtable (); 2006 DtInsertSubtable (ParentTable, Subtable); 2007 2008 /* Compile each ASCII namestring as a subtable */ 2009 2010 while (*PFieldList) 2011 { 2012 Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr, 2013 &Subtable); 2014 if (ACPI_FAILURE (Status)) 2015 { 2016 return (Status); 2017 } 2018 2019 ParentTable = DtPeekSubtable (); 2020 DtInsertSubtable (ParentTable, Subtable); 2021 } 2022 2023 return (AE_OK); 2024 } 2025 2026 2027 /****************************************************************************** 2028 * 2029 * FUNCTION: DtCompileTcpa 2030 * 2031 * PARAMETERS: PFieldList - Current field list pointer 2032 * 2033 * RETURN: Status 2034 * 2035 * DESCRIPTION: Compile TCPA. 2036 * 2037 *****************************************************************************/ 2038 2039 ACPI_STATUS 2040 DtCompileTcpa ( 2041 void **List) 2042 { 2043 DT_FIELD **PFieldList = (DT_FIELD **) List; 2044 DT_SUBTABLE *Subtable; 2045 ACPI_TABLE_TCPA_HDR *TcpaHeader; 2046 DT_SUBTABLE *ParentTable; 2047 ACPI_STATUS Status; 2048 2049 2050 /* Compile the main table */ 2051 2052 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaHdr, 2053 &Subtable); 2054 if (ACPI_FAILURE (Status)) 2055 { 2056 return (Status); 2057 } 2058 2059 ParentTable = DtPeekSubtable (); 2060 DtInsertSubtable (ParentTable, Subtable); 2061 2062 /* 2063 * Examine the PlatformClass field to determine the table type. 2064 * Either a client or server table. Only one. 2065 */ 2066 TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer); 2067 2068 switch (TcpaHeader->PlatformClass) 2069 { 2070 case ACPI_TCPA_CLIENT_TABLE: 2071 2072 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaClient, 2073 &Subtable); 2074 break; 2075 2076 case ACPI_TCPA_SERVER_TABLE: 2077 2078 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTcpaServer, 2079 &Subtable); 2080 break; 2081 2082 default: 2083 2084 AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n", 2085 TcpaHeader->PlatformClass); 2086 Status = AE_ERROR; 2087 break; 2088 } 2089 2090 ParentTable = DtPeekSubtable (); 2091 DtInsertSubtable (ParentTable, Subtable); 2092 return (Status); 2093 } 2094 2095 2096 /****************************************************************************** 2097 * 2098 * FUNCTION: DtCompileTpm2Rev3 2099 * 2100 * PARAMETERS: PFieldList - Current field list pointer 2101 * 2102 * RETURN: Status 2103 * 2104 * DESCRIPTION: Compile TPM2 revision 3 2105 * 2106 *****************************************************************************/ 2107 static ACPI_STATUS 2108 DtCompileTpm2Rev3 ( 2109 void **List) 2110 { 2111 DT_FIELD **PFieldList = (DT_FIELD **) List; 2112 DT_SUBTABLE *Subtable; 2113 ACPI_TABLE_TPM23 *Tpm23Header; 2114 DT_SUBTABLE *ParentTable; 2115 ACPI_STATUS Status = AE_OK; 2116 2117 2118 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm23, 2119 &Subtable); 2120 2121 ParentTable = DtPeekSubtable (); 2122 DtInsertSubtable (ParentTable, Subtable); 2123 Tpm23Header = ACPI_CAST_PTR (ACPI_TABLE_TPM23, ParentTable->Buffer); 2124 2125 /* Subtable type depends on the StartMethod */ 2126 2127 switch (Tpm23Header->StartMethod) 2128 { 2129 case ACPI_TPM23_ACPI_START_METHOD: 2130 2131 /* Subtable specific to to ARM_SMC */ 2132 2133 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm23a, 2134 &Subtable); 2135 if (ACPI_FAILURE (Status)) 2136 { 2137 return (Status); 2138 } 2139 2140 ParentTable = DtPeekSubtable (); 2141 DtInsertSubtable (ParentTable, Subtable); 2142 break; 2143 2144 default: 2145 break; 2146 } 2147 2148 return (Status); 2149 } 2150 2151 2152 /****************************************************************************** 2153 * 2154 * FUNCTION: DtCompileTpm2 2155 * 2156 * PARAMETERS: PFieldList - Current field list pointer 2157 * 2158 * RETURN: Status 2159 * 2160 * DESCRIPTION: Compile TPM2. 2161 * 2162 *****************************************************************************/ 2163 2164 ACPI_STATUS 2165 DtCompileTpm2 ( 2166 void **List) 2167 { 2168 DT_FIELD **PFieldList = (DT_FIELD **) List; 2169 DT_SUBTABLE *Subtable; 2170 ACPI_TABLE_TPM2 *Tpm2Header; 2171 DT_SUBTABLE *ParentTable; 2172 ACPI_STATUS Status = AE_OK; 2173 ACPI_TABLE_HEADER *Header; 2174 2175 2176 ParentTable = DtPeekSubtable (); 2177 2178 Header = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); 2179 2180 if (Header->Revision == 3) 2181 { 2182 return (DtCompileTpm2Rev3 (List)); 2183 } 2184 2185 /* Compile the main table */ 2186 2187 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2, 2188 &Subtable); 2189 if (ACPI_FAILURE (Status)) 2190 { 2191 return (Status); 2192 } 2193 2194 ParentTable = DtPeekSubtable (); 2195 DtInsertSubtable (ParentTable, Subtable); 2196 2197 Tpm2Header = ACPI_CAST_PTR (ACPI_TABLE_TPM2, ParentTable->Buffer); 2198 2199 /* Method parameters */ 2200 /* Optional: Log area minimum length */ 2201 /* Optional: Log area start address */ 2202 /* TBD: Optional fields above not fully implemented (not optional at this time) */ 2203 2204 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm2a, 2205 &Subtable); 2206 if (ACPI_FAILURE (Status)) 2207 { 2208 return (Status); 2209 } 2210 2211 ParentTable = DtPeekSubtable (); 2212 DtInsertSubtable (ParentTable, Subtable); 2213 2214 2215 /* Subtable type depends on the StartMethod */ 2216 2217 switch (Tpm2Header->StartMethod) 2218 { 2219 case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC: 2220 2221 /* Subtable specific to to ARM_SMC */ 2222 2223 Status = DtCompileTable (PFieldList, AcpiDmTableInfoTpm211, 2224 &Subtable); 2225 if (ACPI_FAILURE (Status)) 2226 { 2227 return (Status); 2228 } 2229 2230 ParentTable = DtPeekSubtable (); 2231 DtInsertSubtable (ParentTable, Subtable); 2232 break; 2233 2234 case ACPI_TPM2_START_METHOD: 2235 case ACPI_TPM2_MEMORY_MAPPED: 2236 case ACPI_TPM2_COMMAND_BUFFER: 2237 case ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD: 2238 break; 2239 2240 case ACPI_TPM2_RESERVED1: 2241 case ACPI_TPM2_RESERVED3: 2242 case ACPI_TPM2_RESERVED4: 2243 case ACPI_TPM2_RESERVED5: 2244 case ACPI_TPM2_RESERVED9: 2245 case ACPI_TPM2_RESERVED10: 2246 2247 AcpiOsPrintf ("\n**** Reserved TPM2 Start Method type 0x%X\n", 2248 Tpm2Header->StartMethod); 2249 Status = AE_ERROR; 2250 break; 2251 2252 case ACPI_TPM2_NOT_ALLOWED: 2253 default: 2254 2255 AcpiOsPrintf ("\n**** Unknown TPM2 Start Method type 0x%X\n", 2256 Tpm2Header->StartMethod); 2257 Status = AE_ERROR; 2258 break; 2259 } 2260 2261 return (Status); 2262 } 2263 2264 2265 /****************************************************************************** 2266 * 2267 * FUNCTION: DtGetGenericTableInfo 2268 * 2269 * PARAMETERS: Name - Generic type name 2270 * 2271 * RETURN: Info entry 2272 * 2273 * DESCRIPTION: Obtain table info for a generic name entry 2274 * 2275 *****************************************************************************/ 2276 2277 ACPI_DMTABLE_INFO * 2278 DtGetGenericTableInfo ( 2279 char *Name) 2280 { 2281 ACPI_DMTABLE_INFO *Info; 2282 UINT32 i; 2283 2284 2285 if (!Name) 2286 { 2287 return (NULL); 2288 } 2289 2290 /* Search info table for name match */ 2291 2292 for (i = 0; ; i++) 2293 { 2294 Info = AcpiDmTableInfoGeneric[i]; 2295 if (Info->Opcode == ACPI_DMT_EXIT) 2296 { 2297 Info = NULL; 2298 break; 2299 } 2300 2301 /* Use caseless compare for generic keywords */ 2302 2303 if (!AcpiUtStricmp (Name, Info->Name)) 2304 { 2305 break; 2306 } 2307 } 2308 2309 return (Info); 2310 } 2311 2312 2313 /****************************************************************************** 2314 * 2315 * FUNCTION: DtCompileUefi 2316 * 2317 * PARAMETERS: List - Current field list pointer 2318 * 2319 * RETURN: Status 2320 * 2321 * DESCRIPTION: Compile UEFI. 2322 * 2323 *****************************************************************************/ 2324 2325 ACPI_STATUS 2326 DtCompileUefi ( 2327 void **List) 2328 { 2329 ACPI_STATUS Status; 2330 DT_SUBTABLE *Subtable; 2331 DT_SUBTABLE *ParentTable; 2332 DT_FIELD **PFieldList = (DT_FIELD **) List; 2333 UINT16 *DataOffset; 2334 2335 2336 /* Compile the predefined portion of the UEFI table */ 2337 2338 Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi, 2339 &Subtable); 2340 if (ACPI_FAILURE (Status)) 2341 { 2342 return (Status); 2343 } 2344 2345 DataOffset = (UINT16 *) (Subtable->Buffer + 16); 2346 *DataOffset = sizeof (ACPI_TABLE_UEFI); 2347 2348 ParentTable = DtPeekSubtable (); 2349 DtInsertSubtable (ParentTable, Subtable); 2350 2351 /* 2352 * Compile the "generic" portion of the UEFI table. This 2353 * part of the table is not predefined and any of the generic 2354 * operators may be used. 2355 */ 2356 DtCompileGeneric ((void **) PFieldList, NULL, NULL); 2357 return (AE_OK); 2358 } 2359 2360 2361 /****************************************************************************** 2362 * 2363 * FUNCTION: DtCompileViot 2364 * 2365 * PARAMETERS: List - Current field list pointer 2366 * 2367 * RETURN: Status 2368 * 2369 * DESCRIPTION: Compile VIOT. 2370 * 2371 *****************************************************************************/ 2372 2373 ACPI_STATUS 2374 DtCompileViot ( 2375 void **List) 2376 { 2377 ACPI_STATUS Status; 2378 DT_SUBTABLE *Subtable; 2379 DT_SUBTABLE *ParentTable; 2380 DT_FIELD **PFieldList = (DT_FIELD **) List; 2381 DT_FIELD *SubtableStart; 2382 ACPI_TABLE_VIOT *Viot; 2383 ACPI_VIOT_HEADER *ViotHeader; 2384 ACPI_DMTABLE_INFO *InfoTable; 2385 UINT16 NodeCount; 2386 2387 ParentTable = DtPeekSubtable (); 2388 2389 Status = DtCompileTable (PFieldList, AcpiDmTableInfoViot, &Subtable); 2390 if (ACPI_FAILURE (Status)) 2391 { 2392 return (Status); 2393 } 2394 DtInsertSubtable (ParentTable, Subtable); 2395 2396 /* 2397 * Using ACPI_SUB_PTR, We needn't define a separate structure. Care 2398 * should be taken to avoid accessing ACPI_TABLE_HEADER fields. 2399 */ 2400 Viot = ACPI_SUB_PTR (ACPI_TABLE_VIOT, Subtable->Buffer, 2401 sizeof (ACPI_TABLE_HEADER)); 2402 2403 Viot->NodeOffset = sizeof (ACPI_TABLE_VIOT); 2404 2405 NodeCount = 0; 2406 while (*PFieldList) { 2407 SubtableStart = *PFieldList; 2408 Status = DtCompileTable (PFieldList, AcpiDmTableInfoViotHeader, 2409 &Subtable); 2410 if (ACPI_FAILURE (Status)) 2411 { 2412 return (Status); 2413 } 2414 2415 ParentTable = DtPeekSubtable (); 2416 DtInsertSubtable (ParentTable, Subtable); 2417 DtPushSubtable (Subtable); 2418 2419 ViotHeader = ACPI_CAST_PTR (ACPI_VIOT_HEADER, Subtable->Buffer); 2420 2421 switch (ViotHeader->Type) 2422 { 2423 case ACPI_VIOT_NODE_PCI_RANGE: 2424 2425 InfoTable = AcpiDmTableInfoViot1; 2426 break; 2427 2428 case ACPI_VIOT_NODE_MMIO: 2429 2430 InfoTable = AcpiDmTableInfoViot2; 2431 break; 2432 2433 case ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI: 2434 2435 InfoTable = AcpiDmTableInfoViot3; 2436 break; 2437 2438 case ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO: 2439 2440 InfoTable = AcpiDmTableInfoViot4; 2441 break; 2442 2443 default: 2444 2445 DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "VIOT"); 2446 return (AE_ERROR); 2447 } 2448 2449 Status = DtCompileTable (PFieldList, InfoTable, &Subtable); 2450 if (ACPI_FAILURE (Status)) 2451 { 2452 return (Status); 2453 } 2454 2455 ParentTable = DtPeekSubtable (); 2456 DtInsertSubtable (ParentTable, Subtable); 2457 DtPopSubtable (); 2458 NodeCount++; 2459 } 2460 2461 Viot->NodeCount = NodeCount; 2462 return (AE_OK); 2463 } 2464 2465 2466 /****************************************************************************** 2467 * 2468 * FUNCTION: DtCompileWdat 2469 * 2470 * PARAMETERS: List - Current field list pointer 2471 * 2472 * RETURN: Status 2473 * 2474 * DESCRIPTION: Compile WDAT. 2475 * 2476 *****************************************************************************/ 2477 2478 ACPI_STATUS 2479 DtCompileWdat ( 2480 void **List) 2481 { 2482 ACPI_STATUS Status; 2483 2484 2485 Status = DtCompileTwoSubtables (List, 2486 AcpiDmTableInfoWdat, AcpiDmTableInfoWdat0); 2487 return (Status); 2488 } 2489 2490 2491 /****************************************************************************** 2492 * 2493 * FUNCTION: DtCompileWpbt 2494 * 2495 * PARAMETERS: List - Current field list pointer 2496 * 2497 * RETURN: Status 2498 * 2499 * DESCRIPTION: Compile WPBT. 2500 * 2501 *****************************************************************************/ 2502 2503 ACPI_STATUS 2504 DtCompileWpbt ( 2505 void **List) 2506 { 2507 DT_FIELD **PFieldList = (DT_FIELD **) List; 2508 DT_SUBTABLE *Subtable; 2509 DT_SUBTABLE *ParentTable; 2510 ACPI_TABLE_WPBT *Table; 2511 ACPI_STATUS Status; 2512 UINT16 Length; 2513 2514 2515 /* Compile the main table */ 2516 2517 Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, 2518 &Subtable); 2519 if (ACPI_FAILURE (Status)) 2520 { 2521 return (Status); 2522 } 2523 2524 ParentTable = DtPeekSubtable (); 2525 DtInsertSubtable (ParentTable, Subtable); 2526 2527 /* Compile the argument list subtable */ 2528 2529 Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, 2530 &Subtable); 2531 if (ACPI_FAILURE (Status)) 2532 { 2533 return (Status); 2534 } 2535 2536 /* Extract the length of the Arguments buffer, insert into main table */ 2537 2538 Length = (UINT16) Subtable->TotalLength; 2539 Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer); 2540 Table->ArgumentsLength = Length; 2541 2542 ParentTable = DtPeekSubtable (); 2543 DtInsertSubtable (ParentTable, Subtable); 2544 return (AE_OK); 2545 } 2546 2547 2548 /****************************************************************************** 2549 * 2550 * FUNCTION: DtCompileXsdt 2551 * 2552 * PARAMETERS: List - Current field list pointer 2553 * 2554 * RETURN: Status 2555 * 2556 * DESCRIPTION: Compile XSDT. 2557 * 2558 *****************************************************************************/ 2559 2560 ACPI_STATUS 2561 DtCompileXsdt ( 2562 void **List) 2563 { 2564 DT_SUBTABLE *Subtable; 2565 DT_SUBTABLE *ParentTable; 2566 DT_FIELD *FieldList = *(DT_FIELD **) List; 2567 UINT64 Address; 2568 2569 2570 ParentTable = DtPeekSubtable (); 2571 2572 while (FieldList) 2573 { 2574 DtCompileInteger ((UINT8 *) &Address, FieldList, 8, DT_NON_ZERO); 2575 2576 DtCreateSubtable ((UINT8 *) &Address, 8, &Subtable); 2577 DtInsertSubtable (ParentTable, Subtable); 2578 FieldList = FieldList->Next; 2579 } 2580 2581 return (AE_OK); 2582 } 2583 2584 2585 /****************************************************************************** 2586 * 2587 * FUNCTION: DtCompileGeneric 2588 * 2589 * PARAMETERS: List - Current field list pointer 2590 * Name - Field name to end generic compiling 2591 * Length - Compiled table length to return 2592 * 2593 * RETURN: Status 2594 * 2595 * DESCRIPTION: Compile generic unknown table. 2596 * 2597 *****************************************************************************/ 2598 2599 ACPI_STATUS 2600 DtCompileGeneric ( 2601 void **List, 2602 char *Name, 2603 UINT32 *Length) 2604 { 2605 ACPI_STATUS Status; 2606 DT_SUBTABLE *Subtable; 2607 DT_SUBTABLE *ParentTable; 2608 DT_FIELD **PFieldList = (DT_FIELD **) List; 2609 ACPI_DMTABLE_INFO *Info; 2610 2611 2612 ParentTable = DtPeekSubtable (); 2613 2614 /* 2615 * Compile the "generic" portion of the table. This 2616 * part of the table is not predefined and any of the generic 2617 * operators may be used. 2618 */ 2619 2620 /* Find any and all labels in the entire generic portion */ 2621 2622 DtDetectAllLabels (*PFieldList); 2623 2624 /* Now we can actually compile the parse tree */ 2625 2626 if (Length && *Length) 2627 { 2628 *Length = 0; 2629 } 2630 while (*PFieldList) 2631 { 2632 if (Name && !strcmp ((*PFieldList)->Name, Name)) 2633 { 2634 break; 2635 } 2636 2637 Info = DtGetGenericTableInfo ((*PFieldList)->Name); 2638 if (!Info) 2639 { 2640 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found", 2641 (*PFieldList)->Name); 2642 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, 2643 (*PFieldList), AslGbl_MsgBuffer); 2644 2645 *PFieldList = (*PFieldList)->Next; 2646 continue; 2647 } 2648 2649 Status = DtCompileTable (PFieldList, Info, 2650 &Subtable); 2651 if (ACPI_SUCCESS (Status)) 2652 { 2653 DtInsertSubtable (ParentTable, Subtable); 2654 if (Length) 2655 { 2656 *Length += Subtable->Length; 2657 } 2658 } 2659 else 2660 { 2661 *PFieldList = (*PFieldList)->Next; 2662 2663 if (Status == AE_NOT_FOUND) 2664 { 2665 sprintf (AslGbl_MsgBuffer, "Generic data type \"%s\" not found", 2666 (*PFieldList)->Name); 2667 DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, 2668 (*PFieldList), AslGbl_MsgBuffer); 2669 } 2670 } 2671 } 2672 2673 return (AE_OK); 2674 } 2675