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