Home | History | Annotate | Line # | Download | only in include
acapps.h revision 1.8
      1 /******************************************************************************
      2  *
      3  * Module Name: acapps - common include for ACPI applications/tools
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2016, 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 #include <stdio.h>
     48 
     49 #ifdef _MSC_VER                 /* disable some level-4 warnings */
     50 #pragma warning(disable:4100)   /* warning C4100: unreferenced formal parameter */
     51 #endif
     52 
     53 /* Common info for tool signons */
     54 
     55 #define ACPICA_NAME                 "Intel ACPI Component Architecture"
     56 #define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2016 Intel Corporation"
     57 
     58 #if ACPI_MACHINE_WIDTH == 64
     59 #define ACPI_WIDTH          "-64"
     60 
     61 #elif ACPI_MACHINE_WIDTH == 32
     62 #define ACPI_WIDTH          "-32"
     63 
     64 #else
     65 #error unknown ACPI_MACHINE_WIDTH
     66 #define ACPI_WIDTH          "-??"
     67 
     68 #endif
     69 
     70 /* Macros for signons and file headers */
     71 #ifdef ACPI_REPRO
     72 #define ACPI_DATE "18 Dec 2013"
     73 #else
     74 #define ACPI_DATE __DATE__
     75 #endif
     76 
     77 #define ACPI_COMMON_SIGNON(UtilityName) \
     78     "\n%s\n%s version %8.8X%s\n%s\n\n", \
     79     ACPICA_NAME, \
     80     UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
     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 /* Macros for usage messages */
     91 
     92 #define ACPI_USAGE_HEADER(Usage) \
     93     AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage);
     94 
     95 #define ACPI_USAGE_TEXT(Description) \
     96     AcpiOsPrintf (Description);
     97 
     98 #define ACPI_OPTION(Name, Description) \
     99     AcpiOsPrintf ("  %-20s%s\n", Name, Description);
    100 
    101 
    102 /* Check for unexpected exceptions */
    103 
    104 #define ACPI_CHECK_STATUS(Name, Status, Expected) \
    105     if (Status != Expected) \
    106     { \
    107         AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \
    108             AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \
    109     }
    110 
    111 /* Check for unexpected non-AE_OK errors */
    112 
    113 
    114 #define ACPI_CHECK_OK(Name, Status)   ACPI_CHECK_STATUS (Name, Status, AE_OK);
    115 
    116 #define FILE_SUFFIX_DISASSEMBLY     "dsl"
    117 #define FILE_SUFFIX_BINARY_TABLE    ".dat" /* Needs the dot */
    118 
    119 
    120 /* acfileio */
    121 
    122 ACPI_STATUS
    123 AcGetAllTablesFromFile (
    124     char                    *Filename,
    125     UINT8                   GetOnlyAmlTables,
    126     ACPI_NEW_TABLE_DESC     **ReturnListHead);
    127 
    128 BOOLEAN
    129 AcIsFileBinary (
    130     FILE                    *File);
    131 
    132 ACPI_STATUS
    133 AcValidateTableHeader (
    134     FILE                    *File,
    135     long                    TableOffset);
    136 
    137 
    138 /* Values for GetOnlyAmlTables */
    139 
    140 #define ACPI_GET_ONLY_AML_TABLES    TRUE
    141 #define ACPI_GET_ALL_TABLES         FALSE
    142 
    143 
    144 /*
    145  * getopt
    146  */
    147 int
    148 AcpiGetopt(
    149     int                     argc,
    150     char                    **argv,
    151     char                    *opts);
    152 
    153 int
    154 AcpiGetoptArgument (
    155     int                     argc,
    156     char                    **argv);
    157 
    158 extern int                  AcpiGbl_Optind;
    159 extern int                  AcpiGbl_Opterr;
    160 extern int                  AcpiGbl_SubOptChar;
    161 extern char                 *AcpiGbl_Optarg;
    162 
    163 
    164 /*
    165  * cmfsize - Common get file size function
    166  */
    167 UINT32
    168 CmGetFileSize (
    169     ACPI_FILE               File);
    170 
    171 
    172 /*
    173  * adwalk
    174  */
    175 void
    176 AcpiDmCrossReferenceNamespace (
    177     ACPI_PARSE_OBJECT       *ParseTreeRoot,
    178     ACPI_NAMESPACE_NODE     *NamespaceRoot,
    179     ACPI_OWNER_ID           OwnerId);
    180 
    181 void
    182 AcpiDmDumpTree (
    183     ACPI_PARSE_OBJECT       *Origin);
    184 
    185 void
    186 AcpiDmFindOrphanMethods (
    187     ACPI_PARSE_OBJECT       *Origin);
    188 
    189 void
    190 AcpiDmFinishNamespaceLoad (
    191     ACPI_PARSE_OBJECT       *ParseTreeRoot,
    192     ACPI_NAMESPACE_NODE     *NamespaceRoot,
    193     ACPI_OWNER_ID           OwnerId);
    194 
    195 void
    196 AcpiDmConvertResourceIndexes (
    197     ACPI_PARSE_OBJECT       *ParseTreeRoot,
    198     ACPI_NAMESPACE_NODE     *NamespaceRoot);
    199 
    200 
    201 /*
    202  * adfile
    203  */
    204 ACPI_STATUS
    205 AdInitialize (
    206     void);
    207 
    208 char *
    209 FlGenerateFilename (
    210     char                    *InputFilename,
    211     char                    *Suffix);
    212 
    213 ACPI_STATUS
    214 FlSplitInputPathname (
    215     char                    *InputPath,
    216     char                    **OutDirectoryPath,
    217     char                    **OutFilename);
    218 
    219 char *
    220 AdGenerateFilename (
    221     char                    *Prefix,
    222     char                    *TableId);
    223 
    224 void
    225 AdWriteTable (
    226     ACPI_TABLE_HEADER       *Table,
    227     UINT32                  Length,
    228     char                    *TableName,
    229     char                    *OemTableId);
    230 
    231 #endif /* _ACAPPS */
    232