blob: ca2c0607104bd59a223f4197a40bdc507ff766a7 [file] [log] [blame]
Lv Zheng506f57d2014-04-04 12:39:42 +08001/******************************************************************************
2 *
3 * Module Name: acapps - common include for ACPI applications/tools
4 *
5 *****************************************************************************/
6
7/*
Bob Moorec8100dc2016-01-15 08:17:03 +08008 * Copyright (C) 2000 - 2016, Intel Corp.
Lv Zheng506f57d2014-04-04 12:39:42 +08009 * 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
Bob Moore2ba73792015-12-29 13:54:58 +080047#include <stdio.h>
48
Lv Zheng506f57d2014-04-04 12:39:42 +080049/* Common info for tool signons */
50
51#define ACPICA_NAME "Intel ACPI Component Architecture"
Bob Moorec8100dc2016-01-15 08:17:03 +080052#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2016 Intel Corporation"
Lv Zheng506f57d2014-04-04 12:39:42 +080053
54#if ACPI_MACHINE_WIDTH == 64
55#define ACPI_WIDTH "-64"
56
57#elif ACPI_MACHINE_WIDTH == 32
58#define ACPI_WIDTH "-32"
59
60#else
61#error unknown ACPI_MACHINE_WIDTH
62#define ACPI_WIDTH "-??"
63
64#endif
65
66/* Macros for signons and file headers */
67
68#define ACPI_COMMON_SIGNON(utility_name) \
Rasmus Villemoes1797d372015-04-13 11:49:18 +080069 "\n%s\n%s version %8.8X%s\n%s\n\n", \
Lv Zheng506f57d2014-04-04 12:39:42 +080070 ACPICA_NAME, \
Rasmus Villemoes1797d372015-04-13 11:49:18 +080071 utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
Lv Zheng506f57d2014-04-04 12:39:42 +080072 ACPICA_COPYRIGHT
73
74#define ACPI_COMMON_HEADER(utility_name, prefix) \
Rasmus Villemoes1797d372015-04-13 11:49:18 +080075 "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
Lv Zheng506f57d2014-04-04 12:39:42 +080076 prefix, ACPICA_NAME, \
Rasmus Villemoes1797d372015-04-13 11:49:18 +080077 prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
Lv Zheng506f57d2014-04-04 12:39:42 +080078 prefix, ACPICA_COPYRIGHT, \
79 prefix
80
81/* Macros for usage messages */
82
83#define ACPI_USAGE_HEADER(usage) \
Lv Zhengd9cf1472014-07-08 10:07:13 +080084 acpi_os_printf ("Usage: %s\nOptions:\n", usage);
85
86#define ACPI_USAGE_TEXT(description) \
87 acpi_os_printf (description);
Lv Zheng506f57d2014-04-04 12:39:42 +080088
89#define ACPI_OPTION(name, description) \
Colin Ian Kingadeb79d2015-12-29 13:59:27 +080090 acpi_os_printf (" %-20s%s\n", name, description);
Lv Zheng506f57d2014-04-04 12:39:42 +080091
Bob Moore3727ec22015-12-29 13:56:46 +080092/* Check for unexpected exceptions */
93
94#define ACPI_CHECK_STATUS(name, status, expected) \
95 if (status != expected) \
96 { \
97 acpi_os_printf ("Unexpected %s from %s (%s-%d)\n", \
98 acpi_format_exception (status), #name, _acpi_module_name, __LINE__); \
99 }
100
101/* Check for unexpected non-AE_OK errors */
102
103#define ACPI_CHECK_OK(name, status) ACPI_CHECK_STATUS (name, status, AE_OK);
104
Lv Zheng506f57d2014-04-04 12:39:42 +0800105#define FILE_SUFFIX_DISASSEMBLY "dsl"
Bob Moore842e71332015-10-19 10:25:04 +0800106#define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */
Lv Zheng506f57d2014-04-04 12:39:42 +0800107
Bob Moore2ba73792015-12-29 13:54:58 +0800108/* acfileio */
109
110acpi_status
Bob Moore395ec732015-12-29 13:55:05 +0800111ac_get_all_tables_from_file(char *filename,
112 u8 get_only_aml_tables,
113 struct acpi_new_table_desc **return_list_head);
114
115u8 ac_is_file_binary(FILE * file);
116
117acpi_status ac_validate_table_header(FILE * file, long table_offset);
Bob Moore2ba73792015-12-29 13:54:58 +0800118
119/* Values for get_only_aml_tables */
120
121#define ACPI_GET_ONLY_AML_TABLES TRUE
122#define ACPI_GET_ALL_TABLES FALSE
123
Lv Zheng506f57d2014-04-04 12:39:42 +0800124/*
125 * getopt
126 */
127int acpi_getopt(int argc, char **argv, char *opts);
128
129int acpi_getopt_argument(int argc, char **argv);
130
131extern int acpi_gbl_optind;
132extern int acpi_gbl_opterr;
133extern int acpi_gbl_sub_opt_char;
134extern char *acpi_gbl_optarg;
135
136/*
137 * cmfsize - Common get file size function
138 */
Lv Zheng3c9349c2014-07-08 10:07:19 +0800139u32 cm_get_file_size(ACPI_FILE file);
Lv Zheng506f57d2014-04-04 12:39:42 +0800140
Lv Zheng506f57d2014-04-04 12:39:42 +0800141/*
142 * adwalk
143 */
144void
145acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root,
146 struct acpi_namespace_node *namespace_root,
147 acpi_owner_id owner_id);
148
149void acpi_dm_dump_tree(union acpi_parse_object *origin);
150
151void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
152
153void
154acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root,
155 struct acpi_namespace_node *namespace_root,
156 acpi_owner_id owner_id);
157
158void
159acpi_dm_convert_resource_indexes(union acpi_parse_object *parse_tree_root,
160 struct acpi_namespace_node *namespace_root);
161
162/*
163 * adfile
164 */
165acpi_status ad_initialize(void);
166
167char *fl_generate_filename(char *input_filename, char *suffix);
168
169acpi_status
170fl_split_input_pathname(char *input_path,
171 char **out_directory_path, char **out_filename);
172
173char *ad_generate_filename(char *prefix, char *table_id);
174
175void
176ad_write_table(struct acpi_table_header *table,
177 u32 length, char *table_name, char *oem_table_id);
Lv Zheng506f57d2014-04-04 12:39:42 +0800178
179#endif /* _ACAPPS */