Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: acapps - common include for ACPI applications/tools |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | c8100dc | 2016-01-15 08:17:03 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2016, Intel Corp. |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 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 | #ifndef _ACAPPS |
| 45 | #define _ACAPPS |
| 46 | |
Lv Zheng | e323c02 | 2016-08-04 16:44:59 +0800 | [diff] [blame] | 47 | #ifdef ACPI_USE_STANDARD_HEADERS |
| 48 | #include <sys/stat.h> |
| 49 | #endif /* ACPI_USE_STANDARD_HEADERS */ |
| 50 | |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 51 | /* Common info for tool signons */ |
| 52 | |
| 53 | #define ACPICA_NAME "Intel ACPI Component Architecture" |
Bob Moore | c8100dc | 2016-01-15 08:17:03 +0800 | [diff] [blame] | 54 | #define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2016 Intel Corporation" |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 55 | |
| 56 | #if ACPI_MACHINE_WIDTH == 64 |
| 57 | #define ACPI_WIDTH "-64" |
| 58 | |
| 59 | #elif ACPI_MACHINE_WIDTH == 32 |
| 60 | #define ACPI_WIDTH "-32" |
| 61 | |
| 62 | #else |
| 63 | #error unknown ACPI_MACHINE_WIDTH |
| 64 | #define ACPI_WIDTH "-??" |
| 65 | |
| 66 | #endif |
| 67 | |
| 68 | /* Macros for signons and file headers */ |
| 69 | |
| 70 | #define ACPI_COMMON_SIGNON(utility_name) \ |
Rasmus Villemoes | 1797d37 | 2015-04-13 11:49:18 +0800 | [diff] [blame] | 71 | "\n%s\n%s version %8.8X%s\n%s\n\n", \ |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 72 | ACPICA_NAME, \ |
Rasmus Villemoes | 1797d37 | 2015-04-13 11:49:18 +0800 | [diff] [blame] | 73 | utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \ |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 74 | ACPICA_COPYRIGHT |
| 75 | |
| 76 | #define ACPI_COMMON_HEADER(utility_name, prefix) \ |
Rasmus Villemoes | 1797d37 | 2015-04-13 11:49:18 +0800 | [diff] [blame] | 77 | "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \ |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 78 | prefix, ACPICA_NAME, \ |
Rasmus Villemoes | 1797d37 | 2015-04-13 11:49:18 +0800 | [diff] [blame] | 79 | prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \ |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 80 | prefix, ACPICA_COPYRIGHT, \ |
| 81 | prefix |
| 82 | |
| 83 | /* Macros for usage messages */ |
| 84 | |
| 85 | #define ACPI_USAGE_HEADER(usage) \ |
Lv Zheng | 911a9b8 | 2016-08-04 16:45:22 +0800 | [diff] [blame] | 86 | printf ("Usage: %s\nOptions:\n", usage); |
Lv Zheng | d9cf147 | 2014-07-08 10:07:13 +0800 | [diff] [blame] | 87 | |
| 88 | #define ACPI_USAGE_TEXT(description) \ |
Lv Zheng | 911a9b8 | 2016-08-04 16:45:22 +0800 | [diff] [blame] | 89 | printf (description); |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 90 | |
| 91 | #define ACPI_OPTION(name, description) \ |
Lv Zheng | 911a9b8 | 2016-08-04 16:45:22 +0800 | [diff] [blame] | 92 | printf (" %-20s%s\n", name, description); |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 93 | |
Bob Moore | 3727ec2 | 2015-12-29 13:56:46 +0800 | [diff] [blame] | 94 | /* Check for unexpected exceptions */ |
| 95 | |
| 96 | #define ACPI_CHECK_STATUS(name, status, expected) \ |
| 97 | if (status != expected) \ |
| 98 | { \ |
| 99 | acpi_os_printf ("Unexpected %s from %s (%s-%d)\n", \ |
| 100 | acpi_format_exception (status), #name, _acpi_module_name, __LINE__); \ |
| 101 | } |
| 102 | |
| 103 | /* Check for unexpected non-AE_OK errors */ |
| 104 | |
| 105 | #define ACPI_CHECK_OK(name, status) ACPI_CHECK_STATUS (name, status, AE_OK); |
| 106 | |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 107 | #define FILE_SUFFIX_DISASSEMBLY "dsl" |
Bob Moore | 842e7133 | 2015-10-19 10:25:04 +0800 | [diff] [blame] | 108 | #define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */ |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 109 | |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 110 | /* acfileio */ |
| 111 | |
| 112 | acpi_status |
Bob Moore | 395ec73 | 2015-12-29 13:55:05 +0800 | [diff] [blame] | 113 | ac_get_all_tables_from_file(char *filename, |
| 114 | u8 get_only_aml_tables, |
| 115 | struct acpi_new_table_desc **return_list_head); |
| 116 | |
| 117 | u8 ac_is_file_binary(FILE * file); |
| 118 | |
| 119 | acpi_status ac_validate_table_header(FILE * file, long table_offset); |
Bob Moore | 2ba7379 | 2015-12-29 13:54:58 +0800 | [diff] [blame] | 120 | |
| 121 | /* Values for get_only_aml_tables */ |
| 122 | |
| 123 | #define ACPI_GET_ONLY_AML_TABLES TRUE |
| 124 | #define ACPI_GET_ALL_TABLES FALSE |
| 125 | |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 126 | /* |
| 127 | * getopt |
| 128 | */ |
| 129 | int acpi_getopt(int argc, char **argv, char *opts); |
| 130 | |
| 131 | int acpi_getopt_argument(int argc, char **argv); |
| 132 | |
| 133 | extern int acpi_gbl_optind; |
| 134 | extern int acpi_gbl_opterr; |
| 135 | extern int acpi_gbl_sub_opt_char; |
| 136 | extern char *acpi_gbl_optarg; |
| 137 | |
| 138 | /* |
| 139 | * cmfsize - Common get file size function |
| 140 | */ |
Lv Zheng | 3c9349c | 2014-07-08 10:07:19 +0800 | [diff] [blame] | 141 | u32 cm_get_file_size(ACPI_FILE file); |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 142 | |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 143 | /* |
| 144 | * adwalk |
| 145 | */ |
| 146 | void |
| 147 | acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root, |
| 148 | struct acpi_namespace_node *namespace_root, |
| 149 | acpi_owner_id owner_id); |
| 150 | |
| 151 | void acpi_dm_dump_tree(union acpi_parse_object *origin); |
| 152 | |
| 153 | void acpi_dm_find_orphan_methods(union acpi_parse_object *origin); |
| 154 | |
| 155 | void |
| 156 | acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root, |
| 157 | struct acpi_namespace_node *namespace_root, |
| 158 | acpi_owner_id owner_id); |
| 159 | |
| 160 | void |
| 161 | acpi_dm_convert_resource_indexes(union acpi_parse_object *parse_tree_root, |
| 162 | struct acpi_namespace_node *namespace_root); |
| 163 | |
| 164 | /* |
| 165 | * adfile |
| 166 | */ |
| 167 | acpi_status ad_initialize(void); |
| 168 | |
| 169 | char *fl_generate_filename(char *input_filename, char *suffix); |
| 170 | |
| 171 | acpi_status |
| 172 | fl_split_input_pathname(char *input_path, |
| 173 | char **out_directory_path, char **out_filename); |
| 174 | |
| 175 | char *ad_generate_filename(char *prefix, char *table_id); |
| 176 | |
| 177 | void |
| 178 | ad_write_table(struct acpi_table_header *table, |
| 179 | u32 length, char *table_name, char *oem_table_id); |
Lv Zheng | 506f57d | 2014-04-04 12:39:42 +0800 | [diff] [blame] | 180 | |
| 181 | #endif /* _ACAPPS */ |