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