Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / acpi / acpica / acapps.h
1 /******************************************************************************
2  *
3  * Module Name: acapps - common include for ACPI applications/tools
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2017, 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 #ifndef _ACAPPS
45 #define _ACAPPS
46
47 #ifdef ACPI_USE_STANDARD_HEADERS
48 #include <sys/stat.h>
49 #endif                          /* ACPI_USE_STANDARD_HEADERS */
50
51 /* Common info for tool signons */
52
53 #define ACPICA_NAME                 "Intel ACPI Component Architecture"
54 #define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2017 Intel Corporation"
55
56 #if ACPI_MACHINE_WIDTH == 64
57 #define ACPI_WIDTH          " (64-bit version)"
58
59 #elif ACPI_MACHINE_WIDTH == 32
60 #define ACPI_WIDTH          " (32-bit version)"
61
62 #else
63 #error unknown ACPI_MACHINE_WIDTH
64 #define ACPI_WIDTH          " (unknown bit width, not 32 or 64)"
65
66 #endif
67
68 /* Macros for signons and file headers */
69
70 #define ACPI_COMMON_SIGNON(utility_name) \
71         "\n%s\n%s version %8.8X\n%s\n\n", \
72         ACPICA_NAME, \
73         utility_name, ((u32) ACPI_CA_VERSION), \
74         ACPICA_COPYRIGHT
75
76 #define ACPI_COMMON_HEADER(utility_name, prefix) \
77         "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
78         prefix, ACPICA_NAME, \
79         prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
80         prefix, ACPICA_COPYRIGHT, \
81         prefix
82
83 #define ACPI_COMMON_BUILD_TIME \
84         "Build date/time: %s %s\n", __DATE__, __TIME__
85
86 /* Macros for usage messages */
87
88 #define ACPI_USAGE_HEADER(usage) \
89         printf ("Usage: %s\nOptions:\n", usage);
90
91 #define ACPI_USAGE_TEXT(description) \
92         printf (description);
93
94 #define ACPI_OPTION(name, description) \
95         printf ("  %-20s%s\n", name, description);
96
97 /* Check for unexpected exceptions */
98
99 #define ACPI_CHECK_STATUS(name, status, expected) \
100         if (status != expected) \
101         { \
102                 acpi_os_printf ("Unexpected %s from %s (%s-%d)\n", \
103                         acpi_format_exception (status), #name, _acpi_module_name, __LINE__); \
104         }
105
106 /* Check for unexpected non-AE_OK errors */
107
108 #define ACPI_CHECK_OK(name, status)   ACPI_CHECK_STATUS (name, status, AE_OK);
109
110 #define FILE_SUFFIX_DISASSEMBLY     "dsl"
111 #define FILE_SUFFIX_BINARY_TABLE    ".dat"      /* Needs the dot */
112
113 /* acfileio */
114
115 acpi_status
116 ac_get_all_tables_from_file(char *filename,
117                             u8 get_only_aml_tables,
118                             struct acpi_new_table_desc **return_list_head);
119
120 void ac_delete_table_list(struct acpi_new_table_desc *list_head);
121
122 u8 ac_is_file_binary(FILE * file);
123
124 acpi_status ac_validate_table_header(FILE * file, long table_offset);
125
126 /* Values for get_only_aml_tables */
127
128 #define ACPI_GET_ONLY_AML_TABLES    TRUE
129 #define ACPI_GET_ALL_TABLES         FALSE
130
131 /*
132  * getopt
133  */
134 int acpi_getopt(int argc, char **argv, char *opts);
135
136 int acpi_getopt_argument(int argc, char **argv);
137
138 extern int acpi_gbl_optind;
139 extern int acpi_gbl_opterr;
140 extern int acpi_gbl_sub_opt_char;
141 extern char *acpi_gbl_optarg;
142
143 /*
144  * cmfsize - Common get file size function
145  */
146 u32 cm_get_file_size(ACPI_FILE file);
147
148 /*
149  * adwalk
150  */
151 void
152 acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root,
153                                   struct acpi_namespace_node *namespace_root,
154                                   acpi_owner_id owner_id);
155
156 void acpi_dm_dump_tree(union acpi_parse_object *origin);
157
158 void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
159
160 void
161 acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root,
162                               struct acpi_namespace_node *namespace_root,
163                               acpi_owner_id owner_id);
164
165 void
166 acpi_dm_convert_parse_objects(union acpi_parse_object *parse_tree_root,
167                               struct acpi_namespace_node *namespace_root);
168
169 /*
170  * adfile
171  */
172 acpi_status ad_initialize(void);
173
174 char *fl_generate_filename(char *input_filename, char *suffix);
175
176 acpi_status
177 fl_split_input_pathname(char *input_path,
178                         char **out_directory_path, char **out_filename);
179
180 char *ad_generate_filename(char *prefix, char *table_id);
181
182 void
183 ad_write_table(struct acpi_table_header *table,
184                u32 length, char *table_name, char *oem_table_id);
185
186 #endif                          /* _ACAPPS */