Home | History | Annotate | Line # | Download | only in acpixtract
acpixtract.h revision 1.1.1.4
      1 /******************************************************************************
      2  *
      3  * Module Name: acpixtract.h - Include for acpixtract utility
      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 #include "acpi.h"
     45 #include "accommon.h"
     46 #include "acapps.h"
     47 #include <stdio.h>
     48 
     49 
     50 #undef ACPI_GLOBAL
     51 
     52 #ifdef DEFINE_ACPIXTRACT_GLOBALS
     53 #define ACPI_GLOBAL(type,name) \
     54     extern type name; \
     55     type name
     56 
     57 #else
     58 #define ACPI_GLOBAL(type,name) \
     59     extern type name
     60 #endif
     61 
     62 
     63 /* Options */
     64 
     65 #define AX_EXTRACT_ALL              0
     66 #define AX_LIST_ALL                 1
     67 #define AX_EXTRACT_SIGNATURE        2
     68 #define AX_EXTRACT_AML_TABLES       3
     69 #define AX_EXTRACT_MULTI_TABLE      4
     70 
     71 #define AX_OPTIONAL_TABLES          0
     72 #define AX_REQUIRED_TABLE           1
     73 
     74 #define AX_UTILITY_NAME             "ACPI Binary Table Extraction Utility"
     75 #define AX_SUPPORTED_OPTIONS        "afhlms:v^"
     76 #define AX_MULTI_TABLE_FILENAME     "amltables.dat"
     77 #define AX_TABLE_INFO_FORMAT        "  %4.4s - %7u bytes written (0x%8.8X) - %s\n"
     78 
     79 /* Extraction states */
     80 
     81 #define AX_STATE_FIND_HEADER        0
     82 #define AX_STATE_EXTRACT_DATA       1
     83 
     84 /* Miscellaneous constants */
     85 
     86 #define AX_LINE_BUFFER_SIZE         256
     87 #define AX_MIN_BLOCK_HEADER_LENGTH  6   /* strlen ("DSDT @") */
     88 #define AX_IS_TABLE_BLOCK_HEADER    (strlen (Gbl_LineBuffer) < AX_END_OF_HEX_DATA) && (strstr (Gbl_LineBuffer, " @ "))
     89 #define AX_END_OF_HEX_DATA          55
     90 
     91 
     92 typedef struct AxTableInfo
     93 {
     94     UINT32                  Signature;
     95     unsigned int            Instances;
     96     unsigned int            NextInstance;
     97     struct AxTableInfo      *Next;
     98 
     99 } AX_TABLE_INFO;
    100 
    101 
    102 /* Globals */
    103 
    104 ACPI_GLOBAL (char,           Gbl_LineBuffer[AX_LINE_BUFFER_SIZE]);
    105 ACPI_GLOBAL (char,           Gbl_HeaderBuffer[AX_LINE_BUFFER_SIZE]);
    106 ACPI_GLOBAL (char,           Gbl_InstanceBuffer[AX_LINE_BUFFER_SIZE]);
    107 ACPI_GLOBAL (AX_TABLE_INFO, *Gbl_TableListHead);
    108 ACPI_GLOBAL (char,           Gbl_OutputFilename[32]);
    109 ACPI_GLOBAL (unsigned char,  Gbl_BinaryData[16]);
    110 ACPI_GLOBAL (unsigned int,   Gbl_TableCount);
    111 ACPI_GLOBAL (BOOLEAN,        Gbl_ForceExtraction);
    112 
    113 
    114 /*
    115  * acpixtract.c
    116  */
    117 int
    118 AxExtractTables (
    119     char                    *InputPathname,
    120     char                    *Signature,
    121     unsigned int            MinimumInstances);
    122 
    123 int
    124 AxExtractToMultiAmlFile (
    125     char                    *InputPathname);
    126 
    127 int
    128 AxListAllTables (
    129     char                    *InputPathname);
    130 
    131 
    132 /*
    133  * axutils.c
    134  */
    135 unsigned int
    136 AxCountTableInstances (
    137     char                    *InputPathname,
    138     char                    *Signature);
    139 
    140 unsigned int
    141 AxGetNextInstance (
    142     char                    *InputPathname,
    143     char                    *Signature);
    144 
    145 void
    146 AxNormalizeSignature (
    147     char                    *Signature);
    148 
    149 void
    150 AxCheckAscii (
    151     char                    *Name,
    152     int                     Count);
    153 
    154 BOOLEAN
    155 AxIsFileAscii (
    156     FILE                    *Handle);
    157 
    158 BOOLEAN
    159 AxIsHexDataLine (
    160     void);
    161 
    162 BOOLEAN
    163 AxIsEmptyLine (
    164     char                    *Buffer);
    165 
    166 BOOLEAN
    167 AxIsDataBlockHeader (
    168     void);
    169 
    170 long
    171 AxConvertAndWrite (
    172     FILE                    *OutputFile,
    173     char                    *ThisSignature,
    174     unsigned int            ThisTableBytesWritten);
    175 
    176 size_t
    177 AxConvertToBinary (
    178     char                    *InputLine,
    179     unsigned char           *OutputData);
    180 
    181 void
    182 AxDumpTableHeader (
    183     unsigned char           *Header);
    184