Home | History | Annotate | Line # | Download | only in include
acapps.h revision 1.14
      1 /******************************************************************************
      2  *
      3  * Module Name: acapps - common include for ACPI applications/tools
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2018, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions, and the following disclaimer,
     16  *    without modification.
     17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  *    including a substantially similar Disclaimer requirement for further
     21  *    binary redistribution.
     22  * 3. Neither the names of the above-listed copyright holders nor the names
     23  *    of any contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * Alternatively, this software may be distributed under the terms of the
     27  * GNU General Public License ("GPL") version 2 as published by the Free
     28  * Software Foundation.
     29  *
     30  * NO WARRANTY
     31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  * POSSIBILITY OF SUCH DAMAGES.
     42  */
     43 
     44 #ifndef _ACAPPS
     45 #define _ACAPPS
     46 
     47 #ifdef ACPI_USE_STANDARD_HEADERS
     48 #include <sys/stat.h>
     49 #endif /* ACPI_USE_STANDARD_HEADERS */
     50 
     51 /* Common info for tool signons */
     52 
     53 #define ACPICA_NAME                 "Intel ACPI Component Architecture"
     54 #define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2018 Intel Corporation"
     55 
     56 #if ACPI_MACHINE_WIDTH == 64
     57 #define ACPI_WIDTH          " (64-bit version)"
     58 
     59 #elif ACPI_MACHINE_WIDTH == 32
     60 #define ACPI_WIDTH          " (32-bit version)"
     61 
     62 #else
     63 #error unknown ACPI_MACHINE_WIDTH
     64 #define ACPI_WIDTH          " (unknown bit width, not 32 or 64)"
     65 
     66 #endif
     67 
     68 /* Macros for signons and file headers */
     69 #ifdef ACPI_REPRO
     70 #define ACPI_DATE "18 Dec 2013"
     71 #define ACPI_TIME "00:00:00"
     72 #else
     73 #define ACPI_DATE __DATE__
     74 #define ACPI_TIME __TIME__
     75 #endif
     76 
     77 #define ACPI_COMMON_SIGNON(UtilityName) \
     78     "\n%s\n%s version %8.8X\n%s\n\n", \
     79     ACPICA_NAME, \
     80     UtilityName, ((UINT32) ACPI_CA_VERSION), \
     81     ACPICA_COPYRIGHT
     82 
     83 #define ACPI_COMMON_HEADER(UtilityName, Prefix) \
     84     "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
     85     Prefix, ACPICA_NAME, \
     86     Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
     87     Prefix, ACPICA_COPYRIGHT, \
     88     Prefix
     89 
     90 #define ACPI_COMMON_BUILD_TIME \
     91     "Build date/time: %s %s\n", ACPI_DATE, ACPI_TIME
     92 
     93 /* Macros for usage messages */
     94 
     95 #define ACPI_USAGE_HEADER(Usage) \
     96     printf ("Usage: %s\nOptions:\n", Usage);
     97 
     98 #define ACPI_USAGE_TEXT(Description) \
     99     printf (Description);
    100 
    101 #define ACPI_OPTION(Name, Description) \
    102     printf ("  %-20s%s\n", Name, Description);
    103 
    104 
    105 /* Check for unexpected exceptions */
    106 
    107 #define ACPI_CHECK_STATUS(Name, Status, Expected) \
    108     if (Status != Expected) \
    109     { \
    110         AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \
    111             AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \
    112     }
    113 
    114 /* Check for unexpected non-AE_OK errors */
    115 
    116 
    117 #define ACPI_CHECK_OK(Name, Status)   ACPI_CHECK_STATUS (Name, Status, AE_OK);
    118 
    119 #define FILE_SUFFIX_DISASSEMBLY     "dsl"
    120 #define FILE_SUFFIX_BINARY_TABLE    ".dat" /* Needs the dot */
    121 
    122 
    123 /* acfileio */
    124 
    125 ACPI_STATUS
    126 AcGetAllTablesFromFile (
    127     char                    *Filename,
    128     UINT8                   GetOnlyAmlTables,
    129     ACPI_NEW_TABLE_DESC     **ReturnListHead);
    130 
    131 void
    132 AcDeleteTableList (
    133     ACPI_NEW_TABLE_DESC     *ListHead);
    134 
    135 BOOLEAN
    136 AcIsFileBinary (
    137     FILE                    *File);
    138 
    139 ACPI_STATUS
    140 AcValidateTableHeader (
    141     FILE                    *File,
    142     long                    TableOffset);
    143 
    144 
    145 /* Values for GetOnlyAmlTables */
    146 
    147 #define ACPI_GET_ONLY_AML_TABLES    TRUE
    148 #define ACPI_GET_ALL_TABLES         FALSE
    149 
    150 
    151 /*
    152  * getopt
    153  */
    154 int
    155 AcpiGetopt(
    156     int                     argc,
    157     char                    **argv,
    158     char                    *opts);
    159 
    160 int
    161 AcpiGetoptArgument (
    162     int                     argc,
    163     char                    **argv);
    164 
    165 extern int                  AcpiGbl_Optind;
    166 extern int                  AcpiGbl_Opterr;
    167 extern int                  AcpiGbl_SubOptChar;
    168 extern char                 *AcpiGbl_Optarg;
    169 
    170 
    171 /*
    172  * cmfsize - Common get file size function
    173  */
    174 UINT32
    175 CmGetFileSize (
    176     ACPI_FILE               File);
    177 
    178 
    179 /*
    180  * adwalk
    181  */
    182 void
    183 AcpiDmCrossReferenceNamespace (
    184     ACPI_PARSE_OBJECT       *ParseTreeRoot,
    185     ACPI_NAMESPACE_NODE     *NamespaceRoot,
    186     ACPI_OWNER_ID           OwnerId);
    187 
    188 void
    189 AcpiDmDumpTree (
    190     ACPI_PARSE_OBJECT       *Origin);
    191 
    192 void
    193 AcpiDmFindOrphanMethods (
    194     ACPI_PARSE_OBJECT       *Origin);
    195 
    196 void
    197 AcpiDmFinishNamespaceLoad (
    198     ACPI_PARSE_OBJECT       *ParseTreeRoot,
    199     ACPI_NAMESPACE_NODE     *NamespaceRoot,
    200     ACPI_OWNER_ID           OwnerId);
    201 
    202 void
    203 AcpiDmConvertParseObjects (
    204     ACPI_PARSE_OBJECT       *ParseTreeRoot,
    205     ACPI_NAMESPACE_NODE     *NamespaceRoot);
    206 
    207 
    208 /*
    209  * adfile
    210  */
    211 ACPI_STATUS
    212 AdInitialize (
    213     void);
    214 
    215 char *
    216 FlGenerateFilename (
    217     char                    *InputFilename,
    218     char                    *Suffix);
    219 
    220 ACPI_STATUS
    221 FlSplitInputPathname (
    222     char                    *InputPath,
    223     char                    **OutDirectoryPath,
    224     char                    **OutFilename);
    225 
    226 char *
    227 FlGetFileBasename (
    228     char                    *FilePathname);
    229 
    230 char *
    231 AdGenerateFilename (
    232     char                    *Prefix,
    233     char                    *TableId);
    234 
    235 void
    236 AdWriteTable (
    237     ACPI_TABLE_HEADER       *Table,
    238     UINT32                  Length,
    239     char                    *TableName,
    240     char                    *OemTableId);
    241 
    242 #endif /* _ACAPPS */
    243