acapps.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /******************************************************************************
  2. *
  3. * Module Name: acapps - common include for ACPI applications/tools
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, 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. #ifdef ACPI_USE_STANDARD_HEADERS
  45. #include <sys/stat.h>
  46. #endif /* ACPI_USE_STANDARD_HEADERS */
  47. /* Common info for tool signons */
  48. #define ACPICA_NAME "Intel ACPI Component Architecture"
  49. #define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2016 Intel Corporation"
  50. #if ACPI_MACHINE_WIDTH == 64
  51. #define ACPI_WIDTH "-64"
  52. #elif ACPI_MACHINE_WIDTH == 32
  53. #define ACPI_WIDTH "-32"
  54. #else
  55. #error unknown ACPI_MACHINE_WIDTH
  56. #define ACPI_WIDTH "-??"
  57. #endif
  58. /* Macros for signons and file headers */
  59. #define ACPI_COMMON_SIGNON(utility_name) \
  60. "\n%s\n%s version %8.8X%s\n%s\n\n", \
  61. ACPICA_NAME, \
  62. utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
  63. ACPICA_COPYRIGHT
  64. #define ACPI_COMMON_HEADER(utility_name, prefix) \
  65. "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
  66. prefix, ACPICA_NAME, \
  67. prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
  68. prefix, ACPICA_COPYRIGHT, \
  69. prefix
  70. /* Macros for usage messages */
  71. #define ACPI_USAGE_HEADER(usage) \
  72. printf ("Usage: %s\nOptions:\n", usage);
  73. #define ACPI_USAGE_TEXT(description) \
  74. printf (description);
  75. #define ACPI_OPTION(name, description) \
  76. printf (" %-20s%s\n", name, description);
  77. /* Check for unexpected exceptions */
  78. #define ACPI_CHECK_STATUS(name, status, expected) \
  79. if (status != expected) \
  80. { \
  81. acpi_os_printf ("Unexpected %s from %s (%s-%d)\n", \
  82. acpi_format_exception (status), #name, _acpi_module_name, __LINE__); \
  83. }
  84. /* Check for unexpected non-AE_OK errors */
  85. #define ACPI_CHECK_OK(name, status) ACPI_CHECK_STATUS (name, status, AE_OK);
  86. #define FILE_SUFFIX_DISASSEMBLY "dsl"
  87. #define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */
  88. /* acfileio */
  89. acpi_status
  90. ac_get_all_tables_from_file(char *filename,
  91. u8 get_only_aml_tables,
  92. struct acpi_new_table_desc **return_list_head);
  93. u8 ac_is_file_binary(FILE * file);
  94. acpi_status ac_validate_table_header(FILE * file, long table_offset);
  95. /* Values for get_only_aml_tables */
  96. #define ACPI_GET_ONLY_AML_TABLES TRUE
  97. #define ACPI_GET_ALL_TABLES FALSE
  98. /*
  99. * getopt
  100. */
  101. int acpi_getopt(int argc, char **argv, char *opts);
  102. int acpi_getopt_argument(int argc, char **argv);
  103. extern int acpi_gbl_optind;
  104. extern int acpi_gbl_opterr;
  105. extern int acpi_gbl_sub_opt_char;
  106. extern char *acpi_gbl_optarg;
  107. /*
  108. * cmfsize - Common get file size function
  109. */
  110. u32 cm_get_file_size(ACPI_FILE file);
  111. /*
  112. * adwalk
  113. */
  114. void
  115. acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root,
  116. struct acpi_namespace_node *namespace_root,
  117. acpi_owner_id owner_id);
  118. void acpi_dm_dump_tree(union acpi_parse_object *origin);
  119. void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
  120. void
  121. acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root,
  122. struct acpi_namespace_node *namespace_root,
  123. acpi_owner_id owner_id);
  124. void
  125. acpi_dm_convert_resource_indexes(union acpi_parse_object *parse_tree_root,
  126. struct acpi_namespace_node *namespace_root);
  127. /*
  128. * adfile
  129. */
  130. acpi_status ad_initialize(void);
  131. char *fl_generate_filename(char *input_filename, char *suffix);
  132. acpi_status
  133. fl_split_input_pathname(char *input_path,
  134. char **out_directory_path, char **out_filename);
  135. char *ad_generate_filename(char *prefix, char *table_id);
  136. void
  137. ad_write_table(struct acpi_table_header *table,
  138. u32 length, char *table_name, char *oem_table_id);
  139. #endif /* _ACAPPS */