Home | History | Annotate | Line # | Download | only in acpisrc
acpisrc.h revision 1.1.1.2
      1      1.1  jruoho 
      2      1.1  jruoho /******************************************************************************
      3      1.1  jruoho  *
      4      1.1  jruoho  * Module Name: acpisrc.h - Include file for AcpiSrc utility
      5      1.1  jruoho  *
      6      1.1  jruoho  *****************************************************************************/
      7      1.1  jruoho 
      8  1.1.1.2  jruoho /*
      9  1.1.1.2  jruoho  * Copyright (C) 2000 - 2011, Intel Corp.
     10      1.1  jruoho  * All rights reserved.
     11      1.1  jruoho  *
     12  1.1.1.2  jruoho  * Redistribution and use in source and binary forms, with or without
     13  1.1.1.2  jruoho  * modification, are permitted provided that the following conditions
     14  1.1.1.2  jruoho  * are met:
     15  1.1.1.2  jruoho  * 1. Redistributions of source code must retain the above copyright
     16  1.1.1.2  jruoho  *    notice, this list of conditions, and the following disclaimer,
     17  1.1.1.2  jruoho  *    without modification.
     18  1.1.1.2  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     19  1.1.1.2  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     20  1.1.1.2  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     21  1.1.1.2  jruoho  *    including a substantially similar Disclaimer requirement for further
     22  1.1.1.2  jruoho  *    binary redistribution.
     23  1.1.1.2  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     24  1.1.1.2  jruoho  *    of any contributors may be used to endorse or promote products derived
     25  1.1.1.2  jruoho  *    from this software without specific prior written permission.
     26  1.1.1.2  jruoho  *
     27  1.1.1.2  jruoho  * Alternatively, this software may be distributed under the terms of the
     28  1.1.1.2  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     29  1.1.1.2  jruoho  * Software Foundation.
     30  1.1.1.2  jruoho  *
     31  1.1.1.2  jruoho  * NO WARRANTY
     32  1.1.1.2  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     33  1.1.1.2  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     34  1.1.1.2  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     35  1.1.1.2  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     36  1.1.1.2  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  1.1.1.2  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  1.1.1.2  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  1.1.1.2  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     40  1.1.1.2  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     41  1.1.1.2  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     42  1.1.1.2  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     43  1.1.1.2  jruoho  */
     44      1.1  jruoho 
     45      1.1  jruoho 
     46      1.1  jruoho #define LINES_IN_LEGAL_HEADER               105 /* See above */
     47      1.1  jruoho #define LEGAL_HEADER_SIGNATURE              " * 2.1. This is your license from Intel Corp. under its intellectual property"
     48      1.1  jruoho #define LINES_IN_LINUX_HEADER               34
     49      1.1  jruoho #define LINUX_HEADER_SIGNATURE              " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"
     50      1.1  jruoho #define LINES_IN_ASL_HEADER                 29 /* Header as output from disassembler */
     51      1.1  jruoho 
     52  1.1.1.2  jruoho #include "acpi.h"
     53  1.1.1.2  jruoho #include "accommon.h"
     54  1.1.1.2  jruoho 
     55      1.1  jruoho #include <stdio.h>
     56      1.1  jruoho #include <sys/stat.h>
     57      1.1  jruoho #include <sys/types.h>
     58      1.1  jruoho #include <fcntl.h>
     59      1.1  jruoho #include <ctype.h>
     60      1.1  jruoho #ifdef WIN32
     61      1.1  jruoho #include <io.h>
     62      1.1  jruoho #include <direct.h>
     63      1.1  jruoho #endif
     64      1.1  jruoho #include <errno.h>
     65      1.1  jruoho 
     66      1.1  jruoho 
     67      1.1  jruoho /* Fixups for non-Win32 compilation */
     68      1.1  jruoho #ifndef WIN32
     69      1.1  jruoho #ifndef O_BINARY
     70      1.1  jruoho #define O_BINARY    0x0
     71      1.1  jruoho #endif
     72      1.1  jruoho 
     73      1.1  jruoho #define mkdir(x) mkdir(x, 0770)
     74      1.1  jruoho char * strlwr(char* str);
     75      1.1  jruoho #endif
     76      1.1  jruoho 
     77      1.1  jruoho 
     78      1.1  jruoho /* Constants */
     79      1.1  jruoho 
     80      1.1  jruoho #define ASRC_MAX_FILE_SIZE                  (1024 * 100)
     81      1.1  jruoho 
     82      1.1  jruoho #define FILE_TYPE_SOURCE                    1
     83      1.1  jruoho #define FILE_TYPE_HEADER                    2
     84      1.1  jruoho #define FILE_TYPE_DIRECTORY                 3
     85      1.1  jruoho 
     86      1.1  jruoho #define CVT_COUNT_TABS                      0x00000001
     87      1.1  jruoho #define CVT_COUNT_NON_ANSI_COMMENTS         0x00000002
     88      1.1  jruoho #define CVT_TRIM_LINES                      0x00000004
     89      1.1  jruoho #define CVT_CHECK_BRACES                    0x00000008
     90      1.1  jruoho #define CVT_COUNT_LINES                     0x00000010
     91      1.1  jruoho #define CVT_BRACES_ON_SAME_LINE             0x00000020
     92      1.1  jruoho #define CVT_MIXED_CASE_TO_UNDERSCORES       0x00000040
     93      1.1  jruoho #define CVT_LOWER_CASE_IDENTIFIERS          0x00000080
     94      1.1  jruoho #define CVT_REMOVE_DEBUG_MACROS             0x00000100
     95      1.1  jruoho #define CVT_TRIM_WHITESPACE                 0x00000200  /* Should be after all line removal */
     96      1.1  jruoho #define CVT_REMOVE_EMPTY_BLOCKS             0x00000400  /* Should be after trimming lines */
     97      1.1  jruoho #define CVT_REDUCE_TYPEDEFS                 0x00000800
     98      1.1  jruoho #define CVT_COUNT_SHORTMULTILINE_COMMENTS   0x00001000
     99      1.1  jruoho #define CVT_SPACES_TO_TABS4                 0x40000000  /* Tab conversion should be last */
    100      1.1  jruoho #define CVT_SPACES_TO_TABS8                 0x80000000  /* Tab conversion should be last */
    101      1.1  jruoho 
    102      1.1  jruoho #define FLG_DEFAULT_FLAGS                   0x00000000
    103      1.1  jruoho #define FLG_NO_CARRIAGE_RETURNS             0x00000001
    104      1.1  jruoho #define FLG_NO_FILE_OUTPUT                  0x00000002
    105      1.1  jruoho #define FLG_LOWERCASE_DIRNAMES              0x00000004
    106      1.1  jruoho 
    107      1.1  jruoho #define AS_START_IGNORE                     "/*!"
    108      1.1  jruoho #define AS_STOP_IGNORE                      "!*/"
    109      1.1  jruoho 
    110      1.1  jruoho 
    111      1.1  jruoho /* Globals */
    112      1.1  jruoho 
    113      1.1  jruoho extern UINT32                   Gbl_Files;
    114      1.1  jruoho extern UINT32                   Gbl_MissingBraces;
    115      1.1  jruoho extern UINT32                   Gbl_Tabs;
    116      1.1  jruoho extern UINT32                   Gbl_NonAnsiComments;
    117      1.1  jruoho extern UINT32                   Gbl_SourceLines;
    118      1.1  jruoho extern UINT32                   Gbl_WhiteLines;
    119      1.1  jruoho extern UINT32                   Gbl_CommentLines;
    120      1.1  jruoho extern UINT32                   Gbl_LongLines;
    121      1.1  jruoho extern UINT32                   Gbl_TotalLines;
    122      1.1  jruoho extern UINT32                   Gbl_HeaderSize;
    123      1.1  jruoho extern UINT32                   Gbl_HeaderLines;
    124      1.1  jruoho extern struct stat              Gbl_StatBuf;
    125      1.1  jruoho extern char                     *Gbl_FileBuffer;
    126      1.1  jruoho extern UINT32                   Gbl_TotalSize;
    127      1.1  jruoho extern UINT32                   Gbl_FileSize;
    128      1.1  jruoho extern UINT32                   Gbl_FileType;
    129      1.1  jruoho extern BOOLEAN                  Gbl_VerboseMode;
    130      1.1  jruoho extern BOOLEAN                  Gbl_QuietMode;
    131      1.1  jruoho extern BOOLEAN                  Gbl_BatchMode;
    132      1.1  jruoho extern BOOLEAN                  Gbl_MadeChanges;
    133      1.1  jruoho extern BOOLEAN                  Gbl_Overwrite;
    134      1.1  jruoho extern BOOLEAN                  Gbl_WidenDeclarations;
    135      1.1  jruoho extern BOOLEAN                  Gbl_IgnoreLoneLineFeeds;
    136      1.1  jruoho extern BOOLEAN                  Gbl_HasLoneLineFeeds;
    137      1.1  jruoho extern void                     *Gbl_StructDefs;
    138      1.1  jruoho 
    139      1.1  jruoho #define PARAM_LIST(pl)          pl
    140      1.1  jruoho #define TERSE_PRINT(a)          if (!Gbl_VerboseMode) printf PARAM_LIST(a)
    141      1.1  jruoho #define VERBOSE_PRINT(a)        if (Gbl_VerboseMode) printf PARAM_LIST(a)
    142      1.1  jruoho 
    143      1.1  jruoho #define REPLACE_WHOLE_WORD      0x00
    144      1.1  jruoho #define REPLACE_SUBSTRINGS      0x01
    145      1.1  jruoho #define REPLACE_MASK            0x01
    146      1.1  jruoho 
    147      1.1  jruoho #define EXTRA_INDENT_C          0x02
    148      1.1  jruoho 
    149      1.1  jruoho 
    150      1.1  jruoho /* Conversion table structs */
    151      1.1  jruoho 
    152      1.1  jruoho typedef struct acpi_string_table
    153      1.1  jruoho {
    154      1.1  jruoho     char                        *Target;
    155      1.1  jruoho     char                        *Replacement;
    156      1.1  jruoho     UINT8                       Type;
    157      1.1  jruoho 
    158      1.1  jruoho } ACPI_STRING_TABLE;
    159      1.1  jruoho 
    160      1.1  jruoho 
    161      1.1  jruoho typedef struct acpi_typed_identifier_table
    162      1.1  jruoho {
    163      1.1  jruoho     char                        *Identifier;
    164      1.1  jruoho     UINT8                       Type;
    165      1.1  jruoho 
    166      1.1  jruoho } ACPI_TYPED_IDENTIFIER_TABLE;
    167      1.1  jruoho 
    168      1.1  jruoho #define SRC_TYPE_SIMPLE         0
    169      1.1  jruoho #define SRC_TYPE_STRUCT         1
    170      1.1  jruoho #define SRC_TYPE_UNION          2
    171      1.1  jruoho 
    172      1.1  jruoho 
    173      1.1  jruoho typedef struct acpi_identifier_table
    174      1.1  jruoho {
    175      1.1  jruoho     char                        *Identifier;
    176      1.1  jruoho 
    177      1.1  jruoho } ACPI_IDENTIFIER_TABLE;
    178      1.1  jruoho 
    179      1.1  jruoho typedef struct acpi_conversion_table
    180      1.1  jruoho {
    181      1.1  jruoho     char                        *NewHeader;
    182      1.1  jruoho     UINT32                      Flags;
    183      1.1  jruoho 
    184      1.1  jruoho     ACPI_TYPED_IDENTIFIER_TABLE *LowerCaseTable;
    185      1.1  jruoho 
    186      1.1  jruoho     ACPI_STRING_TABLE           *SourceStringTable;
    187      1.1  jruoho     ACPI_IDENTIFIER_TABLE       *SourceLineTable;
    188      1.1  jruoho     ACPI_IDENTIFIER_TABLE       *SourceConditionalTable;
    189      1.1  jruoho     ACPI_IDENTIFIER_TABLE       *SourceMacroTable;
    190      1.1  jruoho     ACPI_TYPED_IDENTIFIER_TABLE *SourceStructTable;
    191      1.1  jruoho     UINT32                      SourceFunctions;
    192      1.1  jruoho 
    193      1.1  jruoho     ACPI_STRING_TABLE           *HeaderStringTable;
    194      1.1  jruoho     ACPI_IDENTIFIER_TABLE       *HeaderLineTable;
    195      1.1  jruoho     ACPI_IDENTIFIER_TABLE       *HeaderConditionalTable;
    196      1.1  jruoho     ACPI_IDENTIFIER_TABLE       *HeaderMacroTable;
    197      1.1  jruoho     ACPI_TYPED_IDENTIFIER_TABLE *HeaderStructTable;
    198      1.1  jruoho     UINT32                      HeaderFunctions;
    199      1.1  jruoho 
    200      1.1  jruoho } ACPI_CONVERSION_TABLE;
    201      1.1  jruoho 
    202      1.1  jruoho 
    203      1.1  jruoho /* Conversion tables */
    204      1.1  jruoho 
    205      1.1  jruoho extern ACPI_CONVERSION_TABLE       LinuxConversionTable;
    206      1.1  jruoho extern ACPI_CONVERSION_TABLE       CleanupConversionTable;
    207      1.1  jruoho extern ACPI_CONVERSION_TABLE       StatsConversionTable;
    208      1.1  jruoho extern ACPI_CONVERSION_TABLE       CustomConversionTable;
    209  1.1.1.2  jruoho extern ACPI_CONVERSION_TABLE       LicenseConversionTable;
    210      1.1  jruoho 
    211      1.1  jruoho 
    212      1.1  jruoho /* Prototypes */
    213      1.1  jruoho 
    214      1.1  jruoho char *
    215      1.1  jruoho AsSkipUntilChar (
    216      1.1  jruoho     char                    *Buffer,
    217      1.1  jruoho     char                    Target);
    218      1.1  jruoho 
    219      1.1  jruoho char *
    220      1.1  jruoho AsSkipPastChar (
    221      1.1  jruoho     char                    *Buffer,
    222      1.1  jruoho     char                    Target);
    223      1.1  jruoho 
    224      1.1  jruoho char *
    225      1.1  jruoho AsReplaceData (
    226      1.1  jruoho     char                    *Buffer,
    227      1.1  jruoho     UINT32                  LengthToRemove,
    228      1.1  jruoho     char                    *BufferToAdd,
    229      1.1  jruoho     UINT32                  LengthToAdd);
    230      1.1  jruoho 
    231      1.1  jruoho int
    232      1.1  jruoho AsReplaceString (
    233      1.1  jruoho     char                    *Target,
    234      1.1  jruoho     char                    *Replacement,
    235      1.1  jruoho     UINT8                   Type,
    236      1.1  jruoho     char                    *Buffer);
    237      1.1  jruoho 
    238      1.1  jruoho int
    239      1.1  jruoho AsLowerCaseString (
    240      1.1  jruoho     char                    *Target,
    241      1.1  jruoho     char                    *Buffer);
    242      1.1  jruoho 
    243      1.1  jruoho void
    244      1.1  jruoho AsRemoveLine (
    245      1.1  jruoho     char                    *Buffer,
    246      1.1  jruoho     char                    *Keyword);
    247      1.1  jruoho 
    248      1.1  jruoho void
    249      1.1  jruoho AsRemoveMacro (
    250      1.1  jruoho     char                    *Buffer,
    251      1.1  jruoho     char                    *Keyword);
    252      1.1  jruoho 
    253      1.1  jruoho void
    254      1.1  jruoho AsCheckForBraces (
    255      1.1  jruoho     char                    *Buffer,
    256      1.1  jruoho     char                    *Filename);
    257      1.1  jruoho 
    258      1.1  jruoho void
    259      1.1  jruoho AsTrimLines (
    260      1.1  jruoho     char                    *Buffer,
    261      1.1  jruoho     char                    *Filename);
    262      1.1  jruoho 
    263      1.1  jruoho void
    264      1.1  jruoho AsMixedCaseToUnderscores (
    265      1.1  jruoho     char                    *Buffer);
    266      1.1  jruoho 
    267      1.1  jruoho void
    268      1.1  jruoho AsCountTabs (
    269      1.1  jruoho     char                    *Buffer,
    270      1.1  jruoho     char                    *Filename);
    271      1.1  jruoho 
    272      1.1  jruoho void
    273      1.1  jruoho AsBracesOnSameLine (
    274      1.1  jruoho     char                    *Buffer);
    275      1.1  jruoho 
    276      1.1  jruoho void
    277      1.1  jruoho AsLowerCaseIdentifiers (
    278      1.1  jruoho     char                    *Buffer);
    279      1.1  jruoho 
    280      1.1  jruoho void
    281      1.1  jruoho AsReduceTypedefs (
    282      1.1  jruoho     char                    *Buffer,
    283      1.1  jruoho     char                    *Keyword);
    284      1.1  jruoho 
    285      1.1  jruoho void
    286      1.1  jruoho AsRemoveDebugMacros (
    287      1.1  jruoho     char                    *Buffer);
    288      1.1  jruoho 
    289      1.1  jruoho void
    290      1.1  jruoho AsRemoveEmptyBlocks (
    291      1.1  jruoho     char                    *Buffer,
    292      1.1  jruoho     char                    *Filename);
    293      1.1  jruoho 
    294      1.1  jruoho void
    295      1.1  jruoho AsCountSourceLines (
    296      1.1  jruoho     char                    *Buffer,
    297      1.1  jruoho     char                    *Filename);
    298      1.1  jruoho 
    299      1.1  jruoho void
    300      1.1  jruoho AsCountNonAnsiComments (
    301      1.1  jruoho     char                    *Buffer,
    302      1.1  jruoho     char                    *Filename);
    303      1.1  jruoho 
    304      1.1  jruoho void
    305      1.1  jruoho AsTrimWhitespace (
    306      1.1  jruoho     char                    *Buffer);
    307      1.1  jruoho 
    308      1.1  jruoho void
    309      1.1  jruoho AsTabify4 (
    310      1.1  jruoho     char                    *Buffer);
    311      1.1  jruoho 
    312      1.1  jruoho void
    313      1.1  jruoho AsTabify8 (
    314      1.1  jruoho     char                    *Buffer);
    315      1.1  jruoho 
    316      1.1  jruoho void
    317      1.1  jruoho AsRemoveConditionalCompile (
    318      1.1  jruoho     char                    *Buffer,
    319      1.1  jruoho     char                    *Keyword);
    320      1.1  jruoho 
    321      1.1  jruoho ACPI_NATIVE_INT
    322      1.1  jruoho AsProcessTree (
    323      1.1  jruoho     ACPI_CONVERSION_TABLE   *ConversionTable,
    324      1.1  jruoho     char                    *SourcePath,
    325      1.1  jruoho     char                    *TargetPath);
    326      1.1  jruoho 
    327      1.1  jruoho int
    328      1.1  jruoho AsGetFile (
    329      1.1  jruoho     char                    *FileName,
    330      1.1  jruoho     char                    **FileBuffer,
    331      1.1  jruoho     UINT32                  *FileSize);
    332      1.1  jruoho 
    333      1.1  jruoho int
    334      1.1  jruoho AsPutFile (
    335      1.1  jruoho     char                    *Pathname,
    336      1.1  jruoho     char                    *FileBuffer,
    337      1.1  jruoho     UINT32                  SystemFlags);
    338      1.1  jruoho 
    339      1.1  jruoho void
    340      1.1  jruoho AsReplaceHeader (
    341      1.1  jruoho     char                    *Buffer,
    342      1.1  jruoho     char                    *NewHeader);
    343      1.1  jruoho 
    344      1.1  jruoho void
    345      1.1  jruoho AsConvertFile (
    346      1.1  jruoho     ACPI_CONVERSION_TABLE   *ConversionTable,
    347      1.1  jruoho     char                    *FileBuffer,
    348      1.1  jruoho     char                    *Filename,
    349      1.1  jruoho     ACPI_NATIVE_INT         FileType);
    350      1.1  jruoho 
    351      1.1  jruoho ACPI_NATIVE_INT
    352      1.1  jruoho AsProcessOneFile (
    353      1.1  jruoho     ACPI_CONVERSION_TABLE   *ConversionTable,
    354      1.1  jruoho     char                    *SourcePath,
    355      1.1  jruoho     char                    *TargetPath,
    356      1.1  jruoho     int                     MaxPathLength,
    357      1.1  jruoho     char                    *Filename,
    358      1.1  jruoho     ACPI_NATIVE_INT         FileType);
    359      1.1  jruoho 
    360      1.1  jruoho ACPI_NATIVE_INT
    361      1.1  jruoho AsCheckForDirectory (
    362      1.1  jruoho     char                    *SourceDirPath,
    363      1.1  jruoho     char                    *TargetDirPath,
    364      1.1  jruoho     char                    *Filename,
    365      1.1  jruoho     char                    **SourcePath,
    366      1.1  jruoho     char                    **TargetPath);
    367      1.1  jruoho 
    368      1.1  jruoho BOOLEAN
    369      1.1  jruoho AsMatchExactWord (
    370      1.1  jruoho     char                    *Word,
    371      1.1  jruoho     UINT32                  WordLength);
    372      1.1  jruoho 
    373      1.1  jruoho void
    374      1.1  jruoho AsPrint (
    375      1.1  jruoho     char                    *Message,
    376      1.1  jruoho     UINT32                  Count,
    377      1.1  jruoho     char                    *Filename);
    378      1.1  jruoho 
    379      1.1  jruoho void
    380      1.1  jruoho AsInsertPrefix (
    381      1.1  jruoho     char                    *Buffer,
    382      1.1  jruoho     char                    *Keyword,
    383      1.1  jruoho     UINT8                   Type);
    384      1.1  jruoho 
    385      1.1  jruoho char *
    386      1.1  jruoho AsInsertData (
    387      1.1  jruoho     char                    *Buffer,
    388      1.1  jruoho     char                    *BufferToAdd,
    389      1.1  jruoho     UINT32                  LengthToAdd);
    390      1.1  jruoho 
    391      1.1  jruoho char *
    392      1.1  jruoho AsRemoveData (
    393      1.1  jruoho     char                    *StartPointer,
    394      1.1  jruoho     char                    *EndPointer);
    395      1.1  jruoho 
    396      1.1  jruoho void
    397      1.1  jruoho AsInsertCarriageReturns (
    398      1.1  jruoho     char                    *Buffer);
    399      1.1  jruoho 
    400      1.1  jruoho void
    401      1.1  jruoho AsConvertToLineFeeds (
    402      1.1  jruoho     char                    *Buffer);
    403      1.1  jruoho 
    404      1.1  jruoho 
    405