acapps.h 6.1 KB

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