Home | History | Annotate | Line # | Download | only in acpidump
apmain.c revision 1.1.1.1.10.3
      1  1.1.1.1.10.2       tls /******************************************************************************
      2  1.1.1.1.10.2       tls  *
      3  1.1.1.1.10.2       tls  * Module Name: apmain - Main module for the acpidump utility
      4  1.1.1.1.10.2       tls  *
      5  1.1.1.1.10.2       tls  *****************************************************************************/
      6  1.1.1.1.10.2       tls 
      7  1.1.1.1.10.2       tls /*
      8  1.1.1.1.10.3  jdolecek  * Copyright (C) 2000 - 2017, Intel Corp.
      9  1.1.1.1.10.2       tls  * All rights reserved.
     10  1.1.1.1.10.2       tls  *
     11  1.1.1.1.10.2       tls  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.1.10.2       tls  * modification, are permitted provided that the following conditions
     13  1.1.1.1.10.2       tls  * are met:
     14  1.1.1.1.10.2       tls  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.1.10.2       tls  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.1.10.2       tls  *    without modification.
     17  1.1.1.1.10.2       tls  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.1.10.2       tls  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.1.10.2       tls  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.1.10.2       tls  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.1.10.2       tls  *    binary redistribution.
     22  1.1.1.1.10.2       tls  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.1.10.2       tls  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.1.10.2       tls  *    from this software without specific prior written permission.
     25  1.1.1.1.10.2       tls  *
     26  1.1.1.1.10.2       tls  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.1.10.2       tls  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.1.10.2       tls  * Software Foundation.
     29  1.1.1.1.10.2       tls  *
     30  1.1.1.1.10.2       tls  * NO WARRANTY
     31  1.1.1.1.10.2       tls  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.1.10.2       tls  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.1.10.2       tls  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.1.10.2       tls  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.1.10.2       tls  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.1.10.2       tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.1.10.2       tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.1.10.2       tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.1.10.2       tls  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.1.10.2       tls  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.1.10.2       tls  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.1.10.2       tls  */
     43  1.1.1.1.10.2       tls 
     44  1.1.1.1.10.2       tls #define _DECLARE_GLOBALS
     45  1.1.1.1.10.2       tls #include "acpidump.h"
     46  1.1.1.1.10.2       tls 
     47  1.1.1.1.10.2       tls 
     48  1.1.1.1.10.2       tls /*
     49  1.1.1.1.10.2       tls  * acpidump - A portable utility for obtaining system ACPI tables and dumping
     50  1.1.1.1.10.2       tls  * them in an ASCII hex format suitable for binary extraction via acpixtract.
     51  1.1.1.1.10.2       tls  *
     52  1.1.1.1.10.2       tls  * Obtaining the system ACPI tables is an OS-specific operation.
     53  1.1.1.1.10.2       tls  *
     54  1.1.1.1.10.2       tls  * This utility can be ported to any host operating system by providing a
     55  1.1.1.1.10.2       tls  * module containing system-specific versions of these interfaces:
     56  1.1.1.1.10.2       tls  *
     57  1.1.1.1.10.2       tls  *      AcpiOsGetTableByAddress
     58  1.1.1.1.10.2       tls  *      AcpiOsGetTableByIndex
     59  1.1.1.1.10.2       tls  *      AcpiOsGetTableByName
     60  1.1.1.1.10.2       tls  *
     61  1.1.1.1.10.2       tls  * See the ACPICA Reference Guide for the exact definitions of these
     62  1.1.1.1.10.2       tls  * interfaces. Also, see these ACPICA source code modules for example
     63  1.1.1.1.10.2       tls  * implementations:
     64  1.1.1.1.10.2       tls  *
     65  1.1.1.1.10.2       tls  *      source/os_specific/service_layers/oswintbl.c
     66  1.1.1.1.10.2       tls  *      source/os_specific/service_layers/oslinuxtbl.c
     67  1.1.1.1.10.2       tls  */
     68  1.1.1.1.10.2       tls 
     69  1.1.1.1.10.2       tls 
     70  1.1.1.1.10.2       tls /* Local prototypes */
     71  1.1.1.1.10.2       tls 
     72  1.1.1.1.10.2       tls static void
     73  1.1.1.1.10.2       tls ApDisplayUsage (
     74  1.1.1.1.10.2       tls     void);
     75  1.1.1.1.10.2       tls 
     76  1.1.1.1.10.2       tls static int
     77  1.1.1.1.10.2       tls ApDoOptions (
     78  1.1.1.1.10.2       tls     int                     argc,
     79  1.1.1.1.10.2       tls     char                    **argv);
     80  1.1.1.1.10.2       tls 
     81  1.1.1.1.10.3  jdolecek static int
     82  1.1.1.1.10.2       tls ApInsertAction (
     83  1.1.1.1.10.2       tls     char                    *Argument,
     84  1.1.1.1.10.2       tls     UINT32                  ToBeDone);
     85  1.1.1.1.10.2       tls 
     86  1.1.1.1.10.2       tls 
     87  1.1.1.1.10.2       tls /* Table for deferred actions from command line options */
     88  1.1.1.1.10.2       tls 
     89  1.1.1.1.10.2       tls AP_DUMP_ACTION              ActionTable [AP_MAX_ACTIONS];
     90  1.1.1.1.10.2       tls UINT32                      CurrentAction = 0;
     91  1.1.1.1.10.2       tls 
     92  1.1.1.1.10.2       tls 
     93  1.1.1.1.10.2       tls #define AP_UTILITY_NAME             "ACPI Binary Table Dump Utility"
     94  1.1.1.1.10.3  jdolecek #define AP_SUPPORTED_OPTIONS        "?a:bc:f:hn:o:r:sv^xz"
     95  1.1.1.1.10.2       tls 
     96  1.1.1.1.10.2       tls 
     97  1.1.1.1.10.2       tls /******************************************************************************
     98  1.1.1.1.10.2       tls  *
     99  1.1.1.1.10.2       tls  * FUNCTION:    ApDisplayUsage
    100  1.1.1.1.10.2       tls  *
    101  1.1.1.1.10.2       tls  * DESCRIPTION: Usage message for the AcpiDump utility
    102  1.1.1.1.10.2       tls  *
    103  1.1.1.1.10.2       tls  ******************************************************************************/
    104  1.1.1.1.10.2       tls 
    105  1.1.1.1.10.2       tls static void
    106  1.1.1.1.10.2       tls ApDisplayUsage (
    107  1.1.1.1.10.2       tls     void)
    108  1.1.1.1.10.2       tls {
    109  1.1.1.1.10.2       tls 
    110  1.1.1.1.10.2       tls     ACPI_USAGE_HEADER ("acpidump [options]");
    111  1.1.1.1.10.2       tls 
    112  1.1.1.1.10.2       tls     ACPI_OPTION ("-b",                      "Dump tables to binary files");
    113  1.1.1.1.10.2       tls     ACPI_OPTION ("-h -?",                   "This help message");
    114  1.1.1.1.10.2       tls     ACPI_OPTION ("-o <File>",               "Redirect output to file");
    115  1.1.1.1.10.2       tls     ACPI_OPTION ("-r <Address>",            "Dump tables from specified RSDP");
    116  1.1.1.1.10.2       tls     ACPI_OPTION ("-s",                      "Print table summaries only");
    117  1.1.1.1.10.2       tls     ACPI_OPTION ("-v",                      "Display version information");
    118  1.1.1.1.10.3  jdolecek     ACPI_OPTION ("-vd",                     "Display build date and time");
    119  1.1.1.1.10.2       tls     ACPI_OPTION ("-z",                      "Verbose mode");
    120  1.1.1.1.10.2       tls 
    121  1.1.1.1.10.3  jdolecek     ACPI_USAGE_TEXT ("\nTable Options:\n");
    122  1.1.1.1.10.2       tls 
    123  1.1.1.1.10.2       tls     ACPI_OPTION ("-a <Address>",            "Get table via a physical address");
    124  1.1.1.1.10.3  jdolecek     ACPI_OPTION ("-c <on|off>",             "Turning on/off customized table dumping");
    125  1.1.1.1.10.2       tls     ACPI_OPTION ("-f <BinaryFile>",         "Get table via a binary file");
    126  1.1.1.1.10.2       tls     ACPI_OPTION ("-n <Signature>",          "Get table via a name/signature");
    127  1.1.1.1.10.3  jdolecek     ACPI_OPTION ("-x",                      "Use RSDT instead of XSDT");
    128  1.1.1.1.10.2       tls 
    129  1.1.1.1.10.3  jdolecek     ACPI_USAGE_TEXT (
    130  1.1.1.1.10.2       tls         "\n"
    131  1.1.1.1.10.2       tls         "Invocation without parameters dumps all available tables\n"
    132  1.1.1.1.10.2       tls         "Multiple mixed instances of -a, -f, and -n are supported\n\n");
    133  1.1.1.1.10.2       tls }
    134  1.1.1.1.10.2       tls 
    135  1.1.1.1.10.2       tls 
    136  1.1.1.1.10.2       tls /******************************************************************************
    137  1.1.1.1.10.2       tls  *
    138  1.1.1.1.10.2       tls  * FUNCTION:    ApInsertAction
    139  1.1.1.1.10.2       tls  *
    140  1.1.1.1.10.2       tls  * PARAMETERS:  Argument            - Pointer to the argument for this action
    141  1.1.1.1.10.2       tls  *              ToBeDone            - What to do to process this action
    142  1.1.1.1.10.2       tls  *
    143  1.1.1.1.10.3  jdolecek  * RETURN:      Status
    144  1.1.1.1.10.2       tls  *
    145  1.1.1.1.10.2       tls  * DESCRIPTION: Add an action item to the action table
    146  1.1.1.1.10.2       tls  *
    147  1.1.1.1.10.2       tls  ******************************************************************************/
    148  1.1.1.1.10.2       tls 
    149  1.1.1.1.10.3  jdolecek static int
    150  1.1.1.1.10.2       tls ApInsertAction (
    151  1.1.1.1.10.2       tls     char                    *Argument,
    152  1.1.1.1.10.2       tls     UINT32                  ToBeDone)
    153  1.1.1.1.10.2       tls {
    154  1.1.1.1.10.2       tls 
    155  1.1.1.1.10.2       tls     /* Insert action and check for table overflow */
    156  1.1.1.1.10.2       tls 
    157  1.1.1.1.10.2       tls     ActionTable [CurrentAction].Argument = Argument;
    158  1.1.1.1.10.2       tls     ActionTable [CurrentAction].ToBeDone = ToBeDone;
    159  1.1.1.1.10.2       tls 
    160  1.1.1.1.10.2       tls     CurrentAction++;
    161  1.1.1.1.10.2       tls     if (CurrentAction > AP_MAX_ACTIONS)
    162  1.1.1.1.10.2       tls     {
    163  1.1.1.1.10.2       tls         fprintf (stderr, "Too many table options (max %u)\n", AP_MAX_ACTIONS);
    164  1.1.1.1.10.3  jdolecek         return (-1);
    165  1.1.1.1.10.2       tls     }
    166  1.1.1.1.10.3  jdolecek 
    167  1.1.1.1.10.3  jdolecek     return (0);
    168  1.1.1.1.10.2       tls }
    169  1.1.1.1.10.2       tls 
    170  1.1.1.1.10.2       tls 
    171  1.1.1.1.10.2       tls /******************************************************************************
    172  1.1.1.1.10.2       tls  *
    173  1.1.1.1.10.2       tls  * FUNCTION:    ApDoOptions
    174  1.1.1.1.10.2       tls  *
    175  1.1.1.1.10.2       tls  * PARAMETERS:  argc/argv           - Standard argc/argv
    176  1.1.1.1.10.2       tls  *
    177  1.1.1.1.10.2       tls  * RETURN:      Status
    178  1.1.1.1.10.2       tls  *
    179  1.1.1.1.10.2       tls  * DESCRIPTION: Command line option processing. The main actions for getting
    180  1.1.1.1.10.2       tls  *              and dumping tables are deferred via the action table.
    181  1.1.1.1.10.2       tls  *
    182  1.1.1.1.10.2       tls  *****************************************************************************/
    183  1.1.1.1.10.2       tls 
    184  1.1.1.1.10.2       tls static int
    185  1.1.1.1.10.2       tls ApDoOptions (
    186  1.1.1.1.10.2       tls     int                     argc,
    187  1.1.1.1.10.2       tls     char                    **argv)
    188  1.1.1.1.10.2       tls {
    189  1.1.1.1.10.2       tls     int                     j;
    190  1.1.1.1.10.2       tls     ACPI_STATUS             Status;
    191  1.1.1.1.10.2       tls 
    192  1.1.1.1.10.2       tls 
    193  1.1.1.1.10.2       tls     /* Command line options */
    194  1.1.1.1.10.2       tls 
    195  1.1.1.1.10.3  jdolecek     while ((j = AcpiGetopt (argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
    196  1.1.1.1.10.2       tls     {
    197  1.1.1.1.10.2       tls     /*
    198  1.1.1.1.10.2       tls      * Global options
    199  1.1.1.1.10.2       tls      */
    200  1.1.1.1.10.2       tls     case 'b':   /* Dump all input tables to binary files */
    201  1.1.1.1.10.2       tls 
    202  1.1.1.1.10.2       tls         Gbl_BinaryMode = TRUE;
    203  1.1.1.1.10.2       tls         continue;
    204  1.1.1.1.10.2       tls 
    205  1.1.1.1.10.2       tls     case 'c':   /* Dump customized tables */
    206  1.1.1.1.10.2       tls 
    207  1.1.1.1.10.3  jdolecek         if (!strcmp (AcpiGbl_Optarg, "on"))
    208  1.1.1.1.10.3  jdolecek         {
    209  1.1.1.1.10.3  jdolecek             Gbl_DumpCustomizedTables = TRUE;
    210  1.1.1.1.10.3  jdolecek         }
    211  1.1.1.1.10.3  jdolecek         else if (!strcmp (AcpiGbl_Optarg, "off"))
    212  1.1.1.1.10.3  jdolecek         {
    213  1.1.1.1.10.3  jdolecek             Gbl_DumpCustomizedTables = FALSE;
    214  1.1.1.1.10.3  jdolecek         }
    215  1.1.1.1.10.3  jdolecek         else
    216  1.1.1.1.10.3  jdolecek         {
    217  1.1.1.1.10.3  jdolecek             fprintf (stderr, "%s: Cannot handle this switch, please use on|off\n",
    218  1.1.1.1.10.3  jdolecek                 AcpiGbl_Optarg);
    219  1.1.1.1.10.3  jdolecek             return (-1);
    220  1.1.1.1.10.3  jdolecek         }
    221  1.1.1.1.10.2       tls         continue;
    222  1.1.1.1.10.2       tls 
    223  1.1.1.1.10.2       tls     case 'h':
    224  1.1.1.1.10.2       tls     case '?':
    225  1.1.1.1.10.2       tls 
    226  1.1.1.1.10.2       tls         ApDisplayUsage ();
    227  1.1.1.1.10.3  jdolecek         return (1);
    228  1.1.1.1.10.2       tls 
    229  1.1.1.1.10.2       tls     case 'o':   /* Redirect output to a single file */
    230  1.1.1.1.10.2       tls 
    231  1.1.1.1.10.2       tls         if (ApOpenOutputFile (AcpiGbl_Optarg))
    232  1.1.1.1.10.2       tls         {
    233  1.1.1.1.10.3  jdolecek             return (-1);
    234  1.1.1.1.10.2       tls         }
    235  1.1.1.1.10.2       tls         continue;
    236  1.1.1.1.10.2       tls 
    237  1.1.1.1.10.2       tls     case 'r':   /* Dump tables from specified RSDP */
    238  1.1.1.1.10.2       tls 
    239  1.1.1.1.10.3  jdolecek         Status = AcpiUtStrtoul64 (AcpiGbl_Optarg, &Gbl_RsdpBase);
    240  1.1.1.1.10.2       tls         if (ACPI_FAILURE (Status))
    241  1.1.1.1.10.2       tls         {
    242  1.1.1.1.10.2       tls             fprintf (stderr, "%s: Could not convert to a physical address\n",
    243  1.1.1.1.10.2       tls                 AcpiGbl_Optarg);
    244  1.1.1.1.10.3  jdolecek             return (-1);
    245  1.1.1.1.10.2       tls         }
    246  1.1.1.1.10.2       tls         continue;
    247  1.1.1.1.10.2       tls 
    248  1.1.1.1.10.2       tls     case 's':   /* Print table summaries only */
    249  1.1.1.1.10.2       tls 
    250  1.1.1.1.10.2       tls         Gbl_SummaryMode = TRUE;
    251  1.1.1.1.10.2       tls         continue;
    252  1.1.1.1.10.2       tls 
    253  1.1.1.1.10.3  jdolecek     case 'x':   /* Do not use XSDT */
    254  1.1.1.1.10.3  jdolecek 
    255  1.1.1.1.10.3  jdolecek         if (!AcpiGbl_DoNotUseXsdt)
    256  1.1.1.1.10.3  jdolecek         {
    257  1.1.1.1.10.3  jdolecek             AcpiGbl_DoNotUseXsdt = TRUE;
    258  1.1.1.1.10.3  jdolecek         }
    259  1.1.1.1.10.3  jdolecek         else
    260  1.1.1.1.10.3  jdolecek         {
    261  1.1.1.1.10.3  jdolecek             Gbl_DoNotDumpXsdt = TRUE;
    262  1.1.1.1.10.3  jdolecek         }
    263  1.1.1.1.10.3  jdolecek         continue;
    264  1.1.1.1.10.3  jdolecek 
    265  1.1.1.1.10.3  jdolecek     case 'v': /* -v: (Version): signon already emitted, just exit */
    266  1.1.1.1.10.3  jdolecek 
    267  1.1.1.1.10.3  jdolecek         switch (AcpiGbl_Optarg[0])
    268  1.1.1.1.10.3  jdolecek         {
    269  1.1.1.1.10.3  jdolecek         case '^':  /* -v: (Version) */
    270  1.1.1.1.10.3  jdolecek 
    271  1.1.1.1.10.3  jdolecek             fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME));
    272  1.1.1.1.10.3  jdolecek             return (1);
    273  1.1.1.1.10.3  jdolecek 
    274  1.1.1.1.10.3  jdolecek         case 'd':
    275  1.1.1.1.10.2       tls 
    276  1.1.1.1.10.3  jdolecek             fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME));
    277  1.1.1.1.10.3  jdolecek             printf (ACPI_COMMON_BUILD_TIME);
    278  1.1.1.1.10.3  jdolecek             return (1);
    279  1.1.1.1.10.3  jdolecek 
    280  1.1.1.1.10.3  jdolecek         default:
    281  1.1.1.1.10.3  jdolecek 
    282  1.1.1.1.10.3  jdolecek             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
    283  1.1.1.1.10.3  jdolecek             return (-1);
    284  1.1.1.1.10.3  jdolecek         }
    285  1.1.1.1.10.3  jdolecek         break;
    286  1.1.1.1.10.2       tls 
    287  1.1.1.1.10.2       tls     case 'z':   /* Verbose mode */
    288  1.1.1.1.10.2       tls 
    289  1.1.1.1.10.2       tls         Gbl_VerboseMode = TRUE;
    290  1.1.1.1.10.2       tls         fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME));
    291  1.1.1.1.10.2       tls         continue;
    292  1.1.1.1.10.2       tls 
    293  1.1.1.1.10.2       tls     /*
    294  1.1.1.1.10.2       tls      * Table options
    295  1.1.1.1.10.2       tls      */
    296  1.1.1.1.10.2       tls     case 'a':   /* Get table by physical address */
    297  1.1.1.1.10.2       tls 
    298  1.1.1.1.10.3  jdolecek         if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_ADDRESS))
    299  1.1.1.1.10.3  jdolecek         {
    300  1.1.1.1.10.3  jdolecek             return (-1);
    301  1.1.1.1.10.3  jdolecek         }
    302  1.1.1.1.10.2       tls         break;
    303  1.1.1.1.10.2       tls 
    304  1.1.1.1.10.2       tls     case 'f':   /* Get table from a file */
    305  1.1.1.1.10.2       tls 
    306  1.1.1.1.10.3  jdolecek         if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_FILE))
    307  1.1.1.1.10.3  jdolecek         {
    308  1.1.1.1.10.3  jdolecek             return (-1);
    309  1.1.1.1.10.3  jdolecek         }
    310  1.1.1.1.10.2       tls         break;
    311  1.1.1.1.10.2       tls 
    312  1.1.1.1.10.2       tls     case 'n':   /* Get table by input name (signature) */
    313  1.1.1.1.10.2       tls 
    314  1.1.1.1.10.3  jdolecek         if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_NAME))
    315  1.1.1.1.10.3  jdolecek         {
    316  1.1.1.1.10.3  jdolecek             return (-1);
    317  1.1.1.1.10.3  jdolecek         }
    318  1.1.1.1.10.2       tls         break;
    319  1.1.1.1.10.2       tls 
    320  1.1.1.1.10.2       tls     default:
    321  1.1.1.1.10.2       tls 
    322  1.1.1.1.10.2       tls         ApDisplayUsage ();
    323  1.1.1.1.10.3  jdolecek         return (-1);
    324  1.1.1.1.10.2       tls     }
    325  1.1.1.1.10.2       tls 
    326  1.1.1.1.10.2       tls     /* If there are no actions, this means "get/dump all tables" */
    327  1.1.1.1.10.2       tls 
    328  1.1.1.1.10.2       tls     if (CurrentAction == 0)
    329  1.1.1.1.10.2       tls     {
    330  1.1.1.1.10.3  jdolecek         if (ApInsertAction (NULL, AP_DUMP_ALL_TABLES))
    331  1.1.1.1.10.3  jdolecek         {
    332  1.1.1.1.10.3  jdolecek             return (-1);
    333  1.1.1.1.10.3  jdolecek         }
    334  1.1.1.1.10.2       tls     }
    335  1.1.1.1.10.2       tls 
    336  1.1.1.1.10.2       tls     return (0);
    337  1.1.1.1.10.2       tls }
    338  1.1.1.1.10.2       tls 
    339  1.1.1.1.10.2       tls 
    340  1.1.1.1.10.2       tls /******************************************************************************
    341  1.1.1.1.10.2       tls  *
    342  1.1.1.1.10.2       tls  * FUNCTION:    main
    343  1.1.1.1.10.2       tls  *
    344  1.1.1.1.10.2       tls  * PARAMETERS:  argc/argv           - Standard argc/argv
    345  1.1.1.1.10.2       tls  *
    346  1.1.1.1.10.2       tls  * RETURN:      Status
    347  1.1.1.1.10.2       tls  *
    348  1.1.1.1.10.2       tls  * DESCRIPTION: C main function for acpidump utility
    349  1.1.1.1.10.2       tls  *
    350  1.1.1.1.10.2       tls  ******************************************************************************/
    351  1.1.1.1.10.2       tls 
    352  1.1.1.1.10.3  jdolecek #if !defined(_GNU_EFI) && !defined(_EDK2_EFI)
    353  1.1.1.1.10.2       tls int ACPI_SYSTEM_XFACE
    354  1.1.1.1.10.2       tls main (
    355  1.1.1.1.10.2       tls     int                     argc,
    356  1.1.1.1.10.2       tls     char                    *argv[])
    357  1.1.1.1.10.3  jdolecek #else
    358  1.1.1.1.10.3  jdolecek int ACPI_SYSTEM_XFACE
    359  1.1.1.1.10.3  jdolecek acpi_main (
    360  1.1.1.1.10.3  jdolecek     int                     argc,
    361  1.1.1.1.10.3  jdolecek     char                    *argv[])
    362  1.1.1.1.10.3  jdolecek #endif
    363  1.1.1.1.10.2       tls {
    364  1.1.1.1.10.2       tls     int                     Status = 0;
    365  1.1.1.1.10.2       tls     AP_DUMP_ACTION          *Action;
    366  1.1.1.1.10.2       tls     UINT32                  FileSize;
    367  1.1.1.1.10.2       tls     UINT32                  i;
    368  1.1.1.1.10.2       tls 
    369  1.1.1.1.10.2       tls 
    370  1.1.1.1.10.2       tls     ACPI_DEBUG_INITIALIZE (); /* For debug version only */
    371  1.1.1.1.10.3  jdolecek     AcpiOsInitialize ();
    372  1.1.1.1.10.3  jdolecek     Gbl_OutputFile = ACPI_FILE_OUT;
    373  1.1.1.1.10.3  jdolecek     AcpiGbl_IntegerByteWidth = 8;
    374  1.1.1.1.10.2       tls 
    375  1.1.1.1.10.2       tls     /* Process command line options */
    376  1.1.1.1.10.2       tls 
    377  1.1.1.1.10.3  jdolecek     Status = ApDoOptions (argc, argv);
    378  1.1.1.1.10.3  jdolecek     if (Status > 0)
    379  1.1.1.1.10.2       tls     {
    380  1.1.1.1.10.3  jdolecek         return (0);
    381  1.1.1.1.10.3  jdolecek     }
    382  1.1.1.1.10.3  jdolecek     if (Status < 0)
    383  1.1.1.1.10.3  jdolecek     {
    384  1.1.1.1.10.3  jdolecek         return (Status);
    385  1.1.1.1.10.2       tls     }
    386  1.1.1.1.10.2       tls 
    387  1.1.1.1.10.2       tls     /* Get/dump ACPI table(s) as requested */
    388  1.1.1.1.10.2       tls 
    389  1.1.1.1.10.2       tls     for (i = 0; i < CurrentAction; i++)
    390  1.1.1.1.10.2       tls     {
    391  1.1.1.1.10.2       tls         Action = &ActionTable[i];
    392  1.1.1.1.10.2       tls         switch (Action->ToBeDone)
    393  1.1.1.1.10.2       tls         {
    394  1.1.1.1.10.2       tls         case AP_DUMP_ALL_TABLES:
    395  1.1.1.1.10.2       tls 
    396  1.1.1.1.10.2       tls             Status = ApDumpAllTables ();
    397  1.1.1.1.10.2       tls             break;
    398  1.1.1.1.10.2       tls 
    399  1.1.1.1.10.2       tls         case AP_DUMP_TABLE_BY_ADDRESS:
    400  1.1.1.1.10.2       tls 
    401  1.1.1.1.10.2       tls             Status = ApDumpTableByAddress (Action->Argument);
    402  1.1.1.1.10.2       tls             break;
    403  1.1.1.1.10.2       tls 
    404  1.1.1.1.10.2       tls         case AP_DUMP_TABLE_BY_NAME:
    405  1.1.1.1.10.2       tls 
    406  1.1.1.1.10.2       tls             Status = ApDumpTableByName (Action->Argument);
    407  1.1.1.1.10.2       tls             break;
    408  1.1.1.1.10.2       tls 
    409  1.1.1.1.10.2       tls         case AP_DUMP_TABLE_BY_FILE:
    410  1.1.1.1.10.2       tls 
    411  1.1.1.1.10.2       tls             Status = ApDumpTableFromFile (Action->Argument);
    412  1.1.1.1.10.2       tls             break;
    413  1.1.1.1.10.2       tls 
    414  1.1.1.1.10.2       tls         default:
    415  1.1.1.1.10.2       tls 
    416  1.1.1.1.10.2       tls             fprintf (stderr, "Internal error, invalid action: 0x%X\n",
    417  1.1.1.1.10.2       tls                 Action->ToBeDone);
    418  1.1.1.1.10.2       tls             return (-1);
    419  1.1.1.1.10.2       tls         }
    420  1.1.1.1.10.2       tls 
    421  1.1.1.1.10.2       tls         if (Status)
    422  1.1.1.1.10.2       tls         {
    423  1.1.1.1.10.2       tls             return (Status);
    424  1.1.1.1.10.2       tls         }
    425  1.1.1.1.10.2       tls     }
    426  1.1.1.1.10.2       tls 
    427  1.1.1.1.10.3  jdolecek     if (Gbl_OutputFilename)
    428  1.1.1.1.10.2       tls     {
    429  1.1.1.1.10.2       tls         if (Gbl_VerboseMode)
    430  1.1.1.1.10.2       tls         {
    431  1.1.1.1.10.2       tls             /* Summary for the output file */
    432  1.1.1.1.10.2       tls 
    433  1.1.1.1.10.3  jdolecek             FileSize = CmGetFileSize (Gbl_OutputFile);
    434  1.1.1.1.10.2       tls             fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n",
    435  1.1.1.1.10.2       tls                 Gbl_OutputFilename, FileSize, FileSize);
    436  1.1.1.1.10.2       tls         }
    437  1.1.1.1.10.2       tls 
    438  1.1.1.1.10.2       tls         fclose (Gbl_OutputFile);
    439  1.1.1.1.10.2       tls     }
    440  1.1.1.1.10.2       tls 
    441  1.1.1.1.10.2       tls     return (Status);
    442  1.1.1.1.10.2       tls }
    443