Home | History | Annotate | Line # | Download | only in common
dmtbdump3.c revision 1.1.1.11
      1       1.1  christos /******************************************************************************
      2       1.1  christos  *
      3       1.1  christos  * Module Name: dmtbdump3 - Dump ACPI data tables that contain no AML code
      4       1.1  christos  *
      5       1.1  christos  *****************************************************************************/
      6       1.1  christos 
      7       1.1  christos /*
      8  1.1.1.10  christos  * Copyright (C) 2000 - 2023, Intel Corp.
      9       1.1  christos  * All rights reserved.
     10       1.1  christos  *
     11       1.1  christos  * Redistribution and use in source and binary forms, with or without
     12       1.1  christos  * modification, are permitted provided that the following conditions
     13       1.1  christos  * are met:
     14       1.1  christos  * 1. Redistributions of source code must retain the above copyright
     15       1.1  christos  *    notice, this list of conditions, and the following disclaimer,
     16       1.1  christos  *    without modification.
     17       1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18       1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19       1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20       1.1  christos  *    including a substantially similar Disclaimer requirement for further
     21       1.1  christos  *    binary redistribution.
     22       1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23       1.1  christos  *    of any contributors may be used to endorse or promote products derived
     24       1.1  christos  *    from this software without specific prior written permission.
     25       1.1  christos  *
     26       1.1  christos  * Alternatively, this software may be distributed under the terms of the
     27       1.1  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28       1.1  christos  * Software Foundation.
     29       1.1  christos  *
     30       1.1  christos  * NO WARRANTY
     31       1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32       1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33   1.1.1.6  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34       1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35       1.1  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36       1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37       1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38       1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39       1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40       1.1  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41       1.1  christos  * POSSIBILITY OF SUCH DAMAGES.
     42       1.1  christos  */
     43       1.1  christos 
     44       1.1  christos #include "acpi.h"
     45       1.1  christos #include "accommon.h"
     46       1.1  christos #include "acdisasm.h"
     47       1.1  christos #include "actables.h"
     48       1.1  christos 
     49       1.1  christos /* This module used for application-level code only */
     50       1.1  christos 
     51       1.1  christos #define _COMPONENT          ACPI_CA_DISASSEMBLER
     52       1.1  christos         ACPI_MODULE_NAME    ("dmtbdump3")
     53       1.1  christos 
     54       1.1  christos 
     55       1.1  christos /*******************************************************************************
     56       1.1  christos  *
     57       1.1  christos  * FUNCTION:    AcpiDmDumpSlic
     58       1.1  christos  *
     59       1.1  christos  * PARAMETERS:  Table               - A SLIC table
     60       1.1  christos  *
     61       1.1  christos  * RETURN:      None
     62       1.1  christos  *
     63       1.1  christos  * DESCRIPTION: Format the contents of a SLIC
     64       1.1  christos  *
     65       1.1  christos  ******************************************************************************/
     66       1.1  christos 
     67       1.1  christos void
     68       1.1  christos AcpiDmDumpSlic (
     69       1.1  christos     ACPI_TABLE_HEADER       *Table)
     70       1.1  christos {
     71       1.1  christos 
     72  1.1.1.11  christos     (void) AcpiDmDumpTable (Table->Length, sizeof (ACPI_TABLE_HEADER),
     73  1.1.1.11  christos         (void *) (Table + sizeof (*Table)),
     74       1.1  christos         Table->Length - sizeof (*Table), AcpiDmTableInfoSlic);
     75       1.1  christos }
     76       1.1  christos 
     77       1.1  christos 
     78       1.1  christos /*******************************************************************************
     79       1.1  christos  *
     80       1.1  christos  * FUNCTION:    AcpiDmDumpSlit
     81       1.1  christos  *
     82       1.1  christos  * PARAMETERS:  Table               - An SLIT
     83       1.1  christos  *
     84       1.1  christos  * RETURN:      None
     85       1.1  christos  *
     86       1.1  christos  * DESCRIPTION: Format the contents of a SLIT
     87       1.1  christos  *
     88       1.1  christos  ******************************************************************************/
     89       1.1  christos 
     90       1.1  christos void
     91       1.1  christos AcpiDmDumpSlit (
     92       1.1  christos     ACPI_TABLE_HEADER       *Table)
     93       1.1  christos {
     94       1.1  christos     ACPI_STATUS             Status;
     95       1.1  christos     UINT32                  Offset;
     96       1.1  christos     UINT8                   *Row;
     97       1.1  christos     UINT32                  Localities;
     98       1.1  christos     UINT32                  i;
     99       1.1  christos     UINT32                  j;
    100       1.1  christos 
    101       1.1  christos 
    102       1.1  christos     /* Main table */
    103       1.1  christos 
    104       1.1  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSlit);
    105       1.1  christos     if (ACPI_FAILURE (Status))
    106       1.1  christos     {
    107       1.1  christos         return;
    108       1.1  christos     }
    109       1.1  christos 
    110       1.1  christos     /* Display the Locality NxN Matrix */
    111       1.1  christos 
    112       1.1  christos     Localities = (UINT32) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->LocalityCount;
    113       1.1  christos     Offset = ACPI_OFFSET (ACPI_TABLE_SLIT, Entry[0]);
    114       1.1  christos     Row = (UINT8 *) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->Entry;
    115       1.1  christos 
    116       1.1  christos     for (i = 0; i < Localities; i++)
    117       1.1  christos     {
    118       1.1  christos         /* Display one row of the matrix */
    119       1.1  christos 
    120       1.1  christos         AcpiDmLineHeader2 (Offset, Localities, "Locality", i);
    121       1.1  christos         for  (j = 0; j < Localities; j++)
    122       1.1  christos         {
    123       1.1  christos             /* Check for beyond EOT */
    124       1.1  christos 
    125       1.1  christos             if (Offset >= Table->Length)
    126       1.1  christos             {
    127       1.1  christos                 AcpiOsPrintf (
    128       1.1  christos                     "\n**** Not enough room in table for all localities\n");
    129       1.1  christos                 return;
    130       1.1  christos             }
    131       1.1  christos 
    132       1.1  christos             AcpiOsPrintf ("%2.2X", Row[j]);
    133       1.1  christos             Offset++;
    134       1.1  christos 
    135       1.1  christos             /* Display up to 16 bytes per output row */
    136       1.1  christos 
    137       1.1  christos             if ((j+1) < Localities)
    138       1.1  christos             {
    139       1.1  christos                 AcpiOsPrintf (" ");
    140       1.1  christos 
    141       1.1  christos                 if (j && (((j+1) % 16) == 0))
    142       1.1  christos                 {
    143       1.1  christos                     AcpiOsPrintf ("\\\n"); /* With line continuation char */
    144       1.1  christos                     AcpiDmLineHeader (Offset, 0, NULL);
    145       1.1  christos                 }
    146       1.1  christos             }
    147       1.1  christos         }
    148       1.1  christos 
    149       1.1  christos         /* Point to next row */
    150       1.1  christos 
    151       1.1  christos         AcpiOsPrintf ("\n");
    152       1.1  christos         Row += Localities;
    153       1.1  christos     }
    154       1.1  christos }
    155       1.1  christos 
    156       1.1  christos 
    157       1.1  christos /*******************************************************************************
    158       1.1  christos  *
    159       1.1  christos  * FUNCTION:    AcpiDmDumpSrat
    160       1.1  christos  *
    161       1.1  christos  * PARAMETERS:  Table               - A SRAT table
    162       1.1  christos  *
    163       1.1  christos  * RETURN:      None
    164       1.1  christos  *
    165       1.1  christos  * DESCRIPTION: Format the contents of a SRAT
    166       1.1  christos  *
    167       1.1  christos  ******************************************************************************/
    168       1.1  christos 
    169       1.1  christos void
    170       1.1  christos AcpiDmDumpSrat (
    171       1.1  christos     ACPI_TABLE_HEADER       *Table)
    172       1.1  christos {
    173       1.1  christos     ACPI_STATUS             Status;
    174       1.1  christos     UINT32                  Offset = sizeof (ACPI_TABLE_SRAT);
    175       1.1  christos     ACPI_SUBTABLE_HEADER    *Subtable;
    176       1.1  christos     ACPI_DMTABLE_INFO       *InfoTable;
    177       1.1  christos 
    178       1.1  christos 
    179       1.1  christos     /* Main table */
    180       1.1  christos 
    181       1.1  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSrat);
    182       1.1  christos     if (ACPI_FAILURE (Status))
    183       1.1  christos     {
    184       1.1  christos         return;
    185       1.1  christos     }
    186       1.1  christos 
    187       1.1  christos     /* Subtables */
    188       1.1  christos 
    189       1.1  christos     Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset);
    190       1.1  christos     while (Offset < Table->Length)
    191       1.1  christos     {
    192       1.1  christos         /* Common subtable header */
    193       1.1  christos 
    194       1.1  christos         AcpiOsPrintf ("\n");
    195       1.1  christos         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    196       1.1  christos             Subtable->Length, AcpiDmTableInfoSratHdr);
    197       1.1  christos         if (ACPI_FAILURE (Status))
    198       1.1  christos         {
    199       1.1  christos             return;
    200       1.1  christos         }
    201       1.1  christos 
    202       1.1  christos         switch (Subtable->Type)
    203       1.1  christos         {
    204       1.1  christos         case ACPI_SRAT_TYPE_CPU_AFFINITY:
    205       1.1  christos 
    206       1.1  christos             InfoTable = AcpiDmTableInfoSrat0;
    207       1.1  christos             break;
    208       1.1  christos 
    209       1.1  christos         case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
    210       1.1  christos 
    211       1.1  christos             InfoTable = AcpiDmTableInfoSrat1;
    212       1.1  christos             break;
    213       1.1  christos 
    214       1.1  christos         case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
    215       1.1  christos 
    216       1.1  christos             InfoTable = AcpiDmTableInfoSrat2;
    217       1.1  christos             break;
    218       1.1  christos 
    219       1.1  christos         case ACPI_SRAT_TYPE_GICC_AFFINITY:
    220       1.1  christos 
    221       1.1  christos             InfoTable = AcpiDmTableInfoSrat3;
    222       1.1  christos             break;
    223       1.1  christos 
    224       1.1  christos         case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
    225       1.1  christos 
    226       1.1  christos             InfoTable = AcpiDmTableInfoSrat4;
    227       1.1  christos             break;
    228       1.1  christos 
    229   1.1.1.3  christos         case ACPI_SRAT_TYPE_GENERIC_AFFINITY:
    230   1.1.1.3  christos 
    231   1.1.1.3  christos             InfoTable = AcpiDmTableInfoSrat5;
    232   1.1.1.3  christos             break;
    233   1.1.1.3  christos 
    234   1.1.1.8  christos         case ACPI_SRAT_TYPE_GENERIC_PORT_AFFINITY:
    235   1.1.1.8  christos 
    236   1.1.1.8  christos             InfoTable = AcpiDmTableInfoSrat6;
    237   1.1.1.8  christos             break;
    238   1.1.1.8  christos 
    239  1.1.1.11  christos         case ACPI_SRAT_TYPE_RINTC_AFFINITY:
    240  1.1.1.11  christos 
    241  1.1.1.11  christos             InfoTable = AcpiDmTableInfoSrat7;
    242  1.1.1.11  christos             break;
    243  1.1.1.11  christos 
    244       1.1  christos         default:
    245       1.1  christos             AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n",
    246       1.1  christos                 Subtable->Type);
    247       1.1  christos 
    248       1.1  christos             /* Attempt to continue */
    249       1.1  christos 
    250       1.1  christos             if (!Subtable->Length)
    251       1.1  christos             {
    252       1.1  christos                 AcpiOsPrintf ("Invalid zero length subtable\n");
    253       1.1  christos                 return;
    254       1.1  christos             }
    255       1.1  christos             goto NextSubtable;
    256       1.1  christos         }
    257       1.1  christos 
    258       1.1  christos         AcpiOsPrintf ("\n");
    259       1.1  christos         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    260       1.1  christos             Subtable->Length, InfoTable);
    261       1.1  christos         if (ACPI_FAILURE (Status))
    262       1.1  christos         {
    263       1.1  christos             return;
    264       1.1  christos         }
    265       1.1  christos 
    266       1.1  christos NextSubtable:
    267       1.1  christos         /* Point to next subtable */
    268       1.1  christos 
    269       1.1  christos         Offset += Subtable->Length;
    270       1.1  christos         Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Subtable,
    271       1.1  christos             Subtable->Length);
    272       1.1  christos     }
    273       1.1  christos }
    274       1.1  christos 
    275       1.1  christos 
    276       1.1  christos /*******************************************************************************
    277       1.1  christos  *
    278       1.1  christos  * FUNCTION:    AcpiDmDumpStao
    279       1.1  christos  *
    280       1.1  christos  * PARAMETERS:  Table               - A STAO table
    281       1.1  christos  *
    282       1.1  christos  * RETURN:      None
    283       1.1  christos  *
    284       1.1  christos  * DESCRIPTION: Format the contents of a STAO. This is a variable-length
    285       1.1  christos  *              table that contains an open-ended number of ASCII strings
    286       1.1  christos  *              at the end of the table.
    287       1.1  christos  *
    288       1.1  christos  ******************************************************************************/
    289       1.1  christos 
    290       1.1  christos void
    291       1.1  christos AcpiDmDumpStao (
    292       1.1  christos     ACPI_TABLE_HEADER       *Table)
    293       1.1  christos {
    294       1.1  christos     ACPI_STATUS             Status;
    295       1.1  christos     char                    *Namepath;
    296       1.1  christos     UINT32                  Length = Table->Length;
    297       1.1  christos     UINT32                  StringLength;
    298       1.1  christos     UINT32                  Offset = sizeof (ACPI_TABLE_STAO);
    299       1.1  christos 
    300       1.1  christos 
    301       1.1  christos     /* Main table */
    302       1.1  christos 
    303       1.1  christos     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoStao);
    304       1.1  christos     if (ACPI_FAILURE (Status))
    305       1.1  christos     {
    306       1.1  christos         return;
    307       1.1  christos     }
    308       1.1  christos 
    309       1.1  christos     /* The rest of the table consists of Namepath strings */
    310       1.1  christos 
    311       1.1  christos     while (Offset < Table->Length)
    312       1.1  christos     {
    313       1.1  christos         Namepath = ACPI_ADD_PTR (char, Table, Offset);
    314       1.1  christos         StringLength = strlen (Namepath) + 1;
    315       1.1  christos 
    316   1.1.1.4  christos         AcpiDmLineHeader (Offset, StringLength, "Namepath");
    317       1.1  christos         AcpiOsPrintf ("\"%s\"\n", Namepath);
    318       1.1  christos 
    319       1.1  christos         /* Point to next namepath */
    320       1.1  christos 
    321       1.1  christos         Offset += StringLength;
    322       1.1  christos     }
    323       1.1  christos }
    324       1.1  christos 
    325       1.1  christos 
    326       1.1  christos /*******************************************************************************
    327       1.1  christos  *
    328   1.1.1.7  christos  * FUNCTION:    AcpiDmDumpSvkl
    329   1.1.1.7  christos  *
    330   1.1.1.7  christos  * PARAMETERS:  Table               - A SVKL table
    331   1.1.1.7  christos  *
    332   1.1.1.7  christos  * RETURN:      None
    333   1.1.1.7  christos  *
    334   1.1.1.7  christos  * DESCRIPTION: Format the contents of a SVKL. This is a variable-length
    335   1.1.1.7  christos  *              table that contains an open-ended number of key subtables at
    336   1.1.1.7  christos  *              the end of the header.
    337   1.1.1.7  christos  *
    338   1.1.1.7  christos  * NOTES: SVKL is essentially a flat table, with a small main table and
    339   1.1.1.7  christos  *          a variable number of a single type of subtable.
    340   1.1.1.7  christos  *
    341   1.1.1.7  christos  ******************************************************************************/
    342   1.1.1.7  christos 
    343   1.1.1.7  christos void
    344   1.1.1.7  christos AcpiDmDumpSvkl (
    345   1.1.1.7  christos     ACPI_TABLE_HEADER       *Table)
    346   1.1.1.7  christos {
    347   1.1.1.7  christos     ACPI_STATUS             Status;
    348   1.1.1.7  christos     UINT32                  Length = Table->Length;
    349   1.1.1.7  christos     UINT32                  Offset = sizeof (ACPI_TABLE_SVKL);
    350   1.1.1.7  christos     ACPI_SVKL_KEY           *Subtable;
    351   1.1.1.7  christos 
    352   1.1.1.7  christos 
    353   1.1.1.7  christos     /* Main table */
    354   1.1.1.7  christos 
    355   1.1.1.7  christos     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoSvkl);
    356   1.1.1.7  christos     if (ACPI_FAILURE (Status))
    357   1.1.1.7  christos     {
    358   1.1.1.7  christos         return;
    359   1.1.1.7  christos     }
    360   1.1.1.7  christos 
    361   1.1.1.7  christos     /* The rest of the table consists of subtables (single type) */
    362   1.1.1.7  christos 
    363   1.1.1.7  christos     Subtable = ACPI_ADD_PTR (ACPI_SVKL_KEY, Table, Offset);
    364   1.1.1.7  christos     while (Offset < Table->Length)
    365   1.1.1.7  christos     {
    366   1.1.1.7  christos         /* Dump the subtable */
    367   1.1.1.7  christos 
    368   1.1.1.7  christos         AcpiOsPrintf ("\n");
    369   1.1.1.7  christos         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    370   1.1.1.7  christos             sizeof (ACPI_SVKL_KEY), AcpiDmTableInfoSvkl0);
    371   1.1.1.7  christos         if (ACPI_FAILURE (Status))
    372   1.1.1.7  christos         {
    373   1.1.1.7  christos             return;
    374   1.1.1.7  christos         }
    375   1.1.1.7  christos 
    376   1.1.1.7  christos         /* Point to next subtable */
    377   1.1.1.7  christos 
    378   1.1.1.7  christos         Offset += sizeof (ACPI_SVKL_KEY);
    379   1.1.1.7  christos         Subtable = ACPI_ADD_PTR (ACPI_SVKL_KEY, Subtable,
    380   1.1.1.7  christos             sizeof (ACPI_SVKL_KEY));
    381   1.1.1.7  christos     }
    382   1.1.1.7  christos }
    383   1.1.1.7  christos 
    384   1.1.1.7  christos 
    385   1.1.1.7  christos /*******************************************************************************
    386   1.1.1.7  christos  *
    387       1.1  christos  * FUNCTION:    AcpiDmDumpTcpa
    388       1.1  christos  *
    389       1.1  christos  * PARAMETERS:  Table               - A TCPA table
    390       1.1  christos  *
    391       1.1  christos  * RETURN:      None
    392       1.1  christos  *
    393       1.1  christos  * DESCRIPTION: Format the contents of a TCPA.
    394       1.1  christos  *
    395       1.1  christos  * NOTE:        There are two versions of the table with the same signature:
    396       1.1  christos  *              the client version and the server version. The common
    397       1.1  christos  *              PlatformClass field is used to differentiate the two types of
    398       1.1  christos  *              tables.
    399       1.1  christos  *
    400       1.1  christos  ******************************************************************************/
    401       1.1  christos 
    402       1.1  christos void
    403       1.1  christos AcpiDmDumpTcpa (
    404       1.1  christos     ACPI_TABLE_HEADER       *Table)
    405       1.1  christos {
    406       1.1  christos     UINT32                  Offset = sizeof (ACPI_TABLE_TCPA_HDR);
    407       1.1  christos     ACPI_TABLE_TCPA_HDR     *CommonHeader = ACPI_CAST_PTR (
    408       1.1  christos                                 ACPI_TABLE_TCPA_HDR, Table);
    409       1.1  christos     ACPI_TABLE_TCPA_HDR     *Subtable = ACPI_ADD_PTR (
    410       1.1  christos                                 ACPI_TABLE_TCPA_HDR, Table, Offset);
    411       1.1  christos     ACPI_STATUS             Status;
    412       1.1  christos 
    413       1.1  christos 
    414       1.1  christos     /* Main table */
    415       1.1  christos 
    416       1.1  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table,
    417       1.1  christos         0, AcpiDmTableInfoTcpaHdr);
    418       1.1  christos     if (ACPI_FAILURE (Status))
    419       1.1  christos     {
    420       1.1  christos         return;
    421       1.1  christos     }
    422       1.1  christos 
    423       1.1  christos     /*
    424       1.1  christos      * Examine the PlatformClass field to determine the table type.
    425       1.1  christos      * Either a client or server table. Only one.
    426       1.1  christos      */
    427       1.1  christos     switch (CommonHeader->PlatformClass)
    428       1.1  christos     {
    429       1.1  christos     case ACPI_TCPA_CLIENT_TABLE:
    430       1.1  christos 
    431       1.1  christos         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    432       1.1  christos             Table->Length - Offset, AcpiDmTableInfoTcpaClient);
    433       1.1  christos         break;
    434       1.1  christos 
    435       1.1  christos     case ACPI_TCPA_SERVER_TABLE:
    436       1.1  christos 
    437       1.1  christos         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    438       1.1  christos             Table->Length - Offset, AcpiDmTableInfoTcpaServer);
    439       1.1  christos         break;
    440       1.1  christos 
    441       1.1  christos     default:
    442       1.1  christos 
    443       1.1  christos         AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
    444       1.1  christos             CommonHeader->PlatformClass);
    445       1.1  christos         Status = AE_ERROR;
    446       1.1  christos         break;
    447       1.1  christos     }
    448       1.1  christos 
    449       1.1  christos     if (ACPI_FAILURE (Status))
    450       1.1  christos     {
    451       1.1  christos         AcpiOsPrintf ("\n**** Cannot disassemble TCPA table\n");
    452       1.1  christos     }
    453       1.1  christos }
    454       1.1  christos 
    455       1.1  christos 
    456       1.1  christos /*******************************************************************************
    457       1.1  christos  *
    458       1.1  christos  * FUNCTION:    AcpiDmDumpTpm2
    459       1.1  christos  *
    460       1.1  christos  * PARAMETERS:  Table               - A TPM2 table
    461       1.1  christos  *
    462       1.1  christos  * RETURN:      None
    463       1.1  christos  *
    464       1.1  christos  * DESCRIPTION: Format the contents of a TPM2.
    465       1.1  christos  *
    466       1.1  christos  ******************************************************************************/
    467   1.1.1.7  christos 
    468   1.1.1.2  christos static void
    469   1.1.1.2  christos AcpiDmDumpTpm2Rev3 (
    470   1.1.1.2  christos     ACPI_TABLE_HEADER       *Table)
    471   1.1.1.2  christos {
    472   1.1.1.2  christos     UINT32                  Offset = sizeof (ACPI_TABLE_TPM23);
    473   1.1.1.2  christos     ACPI_TABLE_TPM23        *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM23, Table);
    474   1.1.1.2  christos     ACPI_TPM23_TRAILER      *Subtable = ACPI_ADD_PTR (ACPI_TPM23_TRAILER, Table, Offset);
    475   1.1.1.2  christos     ACPI_STATUS             Status;
    476   1.1.1.2  christos 
    477   1.1.1.2  christos 
    478   1.1.1.2  christos     /* Main table */
    479   1.1.1.2  christos 
    480   1.1.1.2  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm23);
    481   1.1.1.2  christos     if (ACPI_FAILURE (Status))
    482   1.1.1.2  christos     {
    483   1.1.1.2  christos         return;
    484   1.1.1.2  christos     }
    485   1.1.1.2  christos 
    486   1.1.1.2  christos     /* Optional subtable if start method is ACPI start method */
    487   1.1.1.2  christos 
    488   1.1.1.2  christos     switch (CommonHeader->StartMethod)
    489   1.1.1.2  christos     {
    490   1.1.1.2  christos     case ACPI_TPM23_ACPI_START_METHOD:
    491   1.1.1.2  christos 
    492   1.1.1.4  christos         (void) AcpiDmDumpTable (Table->Length, Offset, Subtable,
    493   1.1.1.2  christos             Table->Length - Offset, AcpiDmTableInfoTpm23a);
    494   1.1.1.2  christos         break;
    495   1.1.1.2  christos 
    496   1.1.1.2  christos     default:
    497   1.1.1.2  christos         break;
    498   1.1.1.2  christos     }
    499   1.1.1.2  christos }
    500   1.1.1.2  christos 
    501   1.1.1.2  christos 
    502   1.1.1.2  christos /*******************************************************************************
    503   1.1.1.2  christos  *
    504   1.1.1.2  christos  * FUNCTION:    AcpiDmDumpTpm2
    505   1.1.1.2  christos  *
    506   1.1.1.2  christos  * PARAMETERS:  Table               - A TPM2 table
    507   1.1.1.2  christos  *
    508   1.1.1.2  christos  * RETURN:      None
    509   1.1.1.2  christos  *
    510   1.1.1.2  christos  * DESCRIPTION: Format the contents of a TPM2.
    511   1.1.1.2  christos  *
    512   1.1.1.2  christos  ******************************************************************************/
    513       1.1  christos 
    514       1.1  christos void
    515       1.1  christos AcpiDmDumpTpm2 (
    516       1.1  christos     ACPI_TABLE_HEADER       *Table)
    517       1.1  christos {
    518       1.1  christos     UINT32                  Offset = sizeof (ACPI_TABLE_TPM2);
    519       1.1  christos     ACPI_TABLE_TPM2         *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM2, Table);
    520       1.1  christos     ACPI_TPM2_TRAILER       *Subtable = ACPI_ADD_PTR (ACPI_TPM2_TRAILER, Table, Offset);
    521       1.1  christos     ACPI_TPM2_ARM_SMC       *ArmSubtable;
    522       1.1  christos     ACPI_STATUS             Status;
    523       1.1  christos 
    524       1.1  christos 
    525   1.1.1.2  christos     if (Table->Revision == 3)
    526   1.1.1.2  christos     {
    527   1.1.1.2  christos         AcpiDmDumpTpm2Rev3(Table);
    528   1.1.1.2  christos         return;
    529   1.1.1.2  christos     }
    530   1.1.1.2  christos 
    531       1.1  christos     /* Main table */
    532       1.1  christos 
    533       1.1  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm2);
    534   1.1.1.2  christos 
    535       1.1  christos     if (ACPI_FAILURE (Status))
    536       1.1  christos     {
    537       1.1  christos         return;
    538       1.1  christos     }
    539       1.1  christos 
    540       1.1  christos     AcpiOsPrintf ("\n");
    541       1.1  christos     Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    542       1.1  christos         Table->Length - Offset, AcpiDmTableInfoTpm2a);
    543       1.1  christos     if (ACPI_FAILURE (Status))
    544       1.1  christos     {
    545       1.1  christos         return;
    546       1.1  christos     }
    547       1.1  christos 
    548       1.1  christos     switch (CommonHeader->StartMethod)
    549       1.1  christos     {
    550       1.1  christos     case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
    551       1.1  christos 
    552       1.1  christos         ArmSubtable = ACPI_ADD_PTR (ACPI_TPM2_ARM_SMC, Subtable,
    553       1.1  christos             sizeof (ACPI_TPM2_TRAILER));
    554       1.1  christos         Offset += sizeof (ACPI_TPM2_TRAILER);
    555       1.1  christos 
    556       1.1  christos         AcpiOsPrintf ("\n");
    557   1.1.1.4  christos         (void) AcpiDmDumpTable (Table->Length, Offset, ArmSubtable,
    558       1.1  christos             Table->Length - Offset, AcpiDmTableInfoTpm211);
    559       1.1  christos         break;
    560       1.1  christos 
    561       1.1  christos     default:
    562       1.1  christos         break;
    563       1.1  christos     }
    564       1.1  christos }
    565       1.1  christos 
    566       1.1  christos 
    567       1.1  christos /*******************************************************************************
    568       1.1  christos  *
    569   1.1.1.6  christos  * FUNCTION:    AcpiDmDumpViot
    570       1.1  christos  *
    571   1.1.1.6  christos  * PARAMETERS:  Table               - A VIOT table
    572       1.1  christos  *
    573       1.1  christos  * RETURN:      None
    574       1.1  christos  *
    575   1.1.1.6  christos  * DESCRIPTION: Format the contents of a VIOT
    576       1.1  christos  *
    577       1.1  christos  ******************************************************************************/
    578       1.1  christos 
    579       1.1  christos void
    580   1.1.1.6  christos AcpiDmDumpViot (
    581       1.1  christos     ACPI_TABLE_HEADER       *Table)
    582       1.1  christos {
    583       1.1  christos     ACPI_STATUS             Status;
    584   1.1.1.6  christos     ACPI_TABLE_VIOT         *Viot;
    585   1.1.1.6  christos     ACPI_VIOT_HEADER        *ViotHeader;
    586   1.1.1.6  christos     UINT16                  Length;
    587   1.1.1.8  christos     UINT32                  Offset;
    588   1.1.1.6  christos     ACPI_DMTABLE_INFO       *InfoTable;
    589       1.1  christos 
    590       1.1  christos     /* Main table */
    591       1.1  christos 
    592   1.1.1.6  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoViot);
    593       1.1  christos     if (ACPI_FAILURE (Status))
    594       1.1  christos     {
    595       1.1  christos         return;
    596       1.1  christos     }
    597       1.1  christos 
    598   1.1.1.6  christos     Viot = ACPI_CAST_PTR (ACPI_TABLE_VIOT, Table);
    599       1.1  christos 
    600   1.1.1.6  christos     Offset = Viot->NodeOffset;
    601       1.1  christos     while (Offset < Table->Length)
    602       1.1  christos     {
    603       1.1  christos         /* Common subtable header */
    604   1.1.1.6  christos         ViotHeader = ACPI_ADD_PTR (ACPI_VIOT_HEADER, Table, Offset);
    605       1.1  christos         AcpiOsPrintf ("\n");
    606   1.1.1.6  christos 
    607   1.1.1.6  christos         Length = sizeof (ACPI_VIOT_HEADER);
    608   1.1.1.6  christos         Status = AcpiDmDumpTable (Table->Length, Offset, ViotHeader, Length,
    609   1.1.1.6  christos             AcpiDmTableInfoViotHeader);
    610       1.1  christos         if (ACPI_FAILURE (Status))
    611       1.1  christos         {
    612       1.1  christos             return;
    613       1.1  christos         }
    614       1.1  christos 
    615   1.1.1.6  christos         Length = ViotHeader->Length;
    616   1.1.1.6  christos         switch (ViotHeader->Type)
    617   1.1.1.6  christos         {
    618   1.1.1.6  christos         case ACPI_VIOT_NODE_PCI_RANGE:
    619   1.1.1.6  christos 
    620   1.1.1.6  christos             InfoTable = AcpiDmTableInfoViot1;
    621   1.1.1.6  christos             break;
    622   1.1.1.6  christos 
    623   1.1.1.6  christos         case ACPI_VIOT_NODE_MMIO:
    624   1.1.1.6  christos 
    625   1.1.1.6  christos             InfoTable = AcpiDmTableInfoViot2;
    626   1.1.1.6  christos             break;
    627   1.1.1.6  christos 
    628   1.1.1.6  christos         case ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI:
    629   1.1.1.6  christos 
    630   1.1.1.6  christos             InfoTable = AcpiDmTableInfoViot3;
    631   1.1.1.6  christos             break;
    632   1.1.1.6  christos 
    633   1.1.1.6  christos         case ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO:
    634   1.1.1.6  christos 
    635   1.1.1.6  christos             InfoTable = AcpiDmTableInfoViot4;
    636   1.1.1.6  christos             break;
    637       1.1  christos 
    638   1.1.1.6  christos         default:
    639   1.1.1.6  christos 
    640   1.1.1.6  christos             AcpiOsPrintf ("\n*** Unknown VIOT node type 0x%X\n",
    641   1.1.1.6  christos                 ViotHeader->Type);
    642   1.1.1.6  christos 
    643   1.1.1.6  christos             /* Attempt to continue */
    644   1.1.1.6  christos 
    645   1.1.1.6  christos             if (!Length)
    646   1.1.1.6  christos             {
    647   1.1.1.6  christos                 AcpiOsPrintf ("Invalid zero length VIOT node\n");
    648   1.1.1.6  christos                 return;
    649   1.1.1.6  christos             }
    650   1.1.1.6  christos             goto NextSubtable;
    651   1.1.1.6  christos         }
    652   1.1.1.6  christos 
    653   1.1.1.6  christos         AcpiOsPrintf ("\n");
    654   1.1.1.6  christos         Status = AcpiDmDumpTable (Table->Length, Offset, ViotHeader, Length,
    655   1.1.1.6  christos             InfoTable);
    656   1.1.1.6  christos         if (ACPI_FAILURE (Status))
    657   1.1.1.6  christos         {
    658   1.1.1.6  christos             return;
    659   1.1.1.6  christos         }
    660   1.1.1.6  christos 
    661   1.1.1.6  christos NextSubtable:
    662   1.1.1.6  christos         Offset += Length;
    663       1.1  christos     }
    664       1.1  christos }
    665       1.1  christos 
    666       1.1  christos 
    667       1.1  christos /*******************************************************************************
    668       1.1  christos  *
    669       1.1  christos  * FUNCTION:    AcpiDmDumpWdat
    670       1.1  christos  *
    671       1.1  christos  * PARAMETERS:  Table               - A WDAT table
    672       1.1  christos  *
    673       1.1  christos  * RETURN:      None
    674       1.1  christos  *
    675       1.1  christos  * DESCRIPTION: Format the contents of a WDAT
    676       1.1  christos  *
    677       1.1  christos  ******************************************************************************/
    678       1.1  christos 
    679       1.1  christos void
    680       1.1  christos AcpiDmDumpWdat (
    681       1.1  christos     ACPI_TABLE_HEADER       *Table)
    682       1.1  christos {
    683       1.1  christos     ACPI_STATUS             Status;
    684       1.1  christos     UINT32                  Offset = sizeof (ACPI_TABLE_WDAT);
    685       1.1  christos     ACPI_WDAT_ENTRY         *Subtable;
    686       1.1  christos 
    687       1.1  christos 
    688       1.1  christos     /* Main table */
    689       1.1  christos 
    690       1.1  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat);
    691       1.1  christos     if (ACPI_FAILURE (Status))
    692       1.1  christos     {
    693       1.1  christos         return;
    694       1.1  christos     }
    695       1.1  christos 
    696       1.1  christos     /* Subtables */
    697       1.1  christos 
    698       1.1  christos     Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset);
    699       1.1  christos     while (Offset < Table->Length)
    700       1.1  christos     {
    701       1.1  christos         /* Common subtable header */
    702       1.1  christos 
    703       1.1  christos         AcpiOsPrintf ("\n");
    704       1.1  christos         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
    705       1.1  christos             sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0);
    706       1.1  christos         if (ACPI_FAILURE (Status))
    707       1.1  christos         {
    708       1.1  christos             return;
    709       1.1  christos         }
    710       1.1  christos 
    711       1.1  christos         /* Point to next subtable */
    712       1.1  christos 
    713       1.1  christos         Offset += sizeof (ACPI_WDAT_ENTRY);
    714       1.1  christos         Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Subtable,
    715       1.1  christos             sizeof (ACPI_WDAT_ENTRY));
    716       1.1  christos     }
    717       1.1  christos }
    718       1.1  christos 
    719       1.1  christos 
    720       1.1  christos /*******************************************************************************
    721       1.1  christos  *
    722       1.1  christos  * FUNCTION:    AcpiDmDumpWpbt
    723       1.1  christos  *
    724       1.1  christos  * PARAMETERS:  Table               - A WPBT table
    725       1.1  christos  *
    726       1.1  christos  * RETURN:      None
    727       1.1  christos  *
    728       1.1  christos  * DESCRIPTION: Format the contents of a WPBT. This table type consists
    729       1.1  christos  *              of an open-ended arguments buffer at the end of the table.
    730       1.1  christos  *
    731       1.1  christos  ******************************************************************************/
    732       1.1  christos 
    733       1.1  christos void
    734       1.1  christos AcpiDmDumpWpbt (
    735       1.1  christos     ACPI_TABLE_HEADER       *Table)
    736       1.1  christos {
    737       1.1  christos     ACPI_STATUS             Status;
    738       1.1  christos     ACPI_TABLE_WPBT         *Subtable;
    739       1.1  christos     UINT16                  ArgumentsLength;
    740       1.1  christos 
    741       1.1  christos 
    742       1.1  christos     /* Dump the main table */
    743       1.1  christos 
    744   1.1.1.8  christos     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWpbt);
    745       1.1  christos     if (ACPI_FAILURE (Status))
    746       1.1  christos     {
    747       1.1  christos         return;
    748       1.1  christos     }
    749       1.1  christos 
    750       1.1  christos     /* Extract the arguments buffer length from the main table */
    751       1.1  christos 
    752       1.1  christos     Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
    753       1.1  christos     ArgumentsLength = Subtable->ArgumentsLength;
    754       1.1  christos 
    755   1.1.1.8  christos     /* Dump the arguments buffer if present */
    756       1.1  christos 
    757   1.1.1.8  christos     if (ArgumentsLength)
    758   1.1.1.8  christos     {
    759   1.1.1.8  christos         (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
    760   1.1.1.8  christos             AcpiDmTableInfoWpbt0);
    761   1.1.1.8  christos     }
    762       1.1  christos }
    763