xref: /openbmc/linux/drivers/acpi/acpica/acapps.h (revision 19c233b7)
1 /******************************************************************************
2  *
3  * Module Name: acapps - common include for ACPI applications/tools
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2015, 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 /* Common info for tool signons */
48 
49 #define ACPICA_NAME                 "Intel ACPI Component Architecture"
50 #define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2015 Intel Corporation"
51 
52 #if ACPI_MACHINE_WIDTH == 64
53 #define ACPI_WIDTH          "-64"
54 
55 #elif ACPI_MACHINE_WIDTH == 32
56 #define ACPI_WIDTH          "-32"
57 
58 #else
59 #error unknown ACPI_MACHINE_WIDTH
60 #define ACPI_WIDTH          "-??"
61 
62 #endif
63 
64 /* Macros for signons and file headers */
65 
66 #define ACPI_COMMON_SIGNON(utility_name) \
67 	"\n%s\n%s version %8.8X%s\n%s\n\n", \
68 	ACPICA_NAME, \
69 	utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
70 	ACPICA_COPYRIGHT
71 
72 #define ACPI_COMMON_HEADER(utility_name, prefix) \
73 	"%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
74 	prefix, ACPICA_NAME, \
75 	prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
76 	prefix, ACPICA_COPYRIGHT, \
77 	prefix
78 
79 /* Macros for usage messages */
80 
81 #define ACPI_USAGE_HEADER(usage) \
82 	acpi_os_printf ("Usage: %s\nOptions:\n", usage);
83 
84 #define ACPI_USAGE_TEXT(description) \
85 	acpi_os_printf (description);
86 
87 #define ACPI_OPTION(name, description) \
88 	acpi_os_printf (" %-18s%s\n", name, description);
89 
90 #define FILE_SUFFIX_DISASSEMBLY     "dsl"
91 #define ACPI_TABLE_FILE_SUFFIX      ".dat"
92 
93 /*
94  * getopt
95  */
96 int acpi_getopt(int argc, char **argv, char *opts);
97 
98 int acpi_getopt_argument(int argc, char **argv);
99 
100 extern int acpi_gbl_optind;
101 extern int acpi_gbl_opterr;
102 extern int acpi_gbl_sub_opt_char;
103 extern char *acpi_gbl_optarg;
104 
105 /*
106  * cmfsize - Common get file size function
107  */
108 u32 cm_get_file_size(ACPI_FILE file);
109 
110 #ifndef ACPI_DUMP_APP
111 /*
112  * adisasm
113  */
114 acpi_status
115 ad_aml_disassemble(u8 out_to_file,
116 		   char *filename, char *prefix, char **out_filename);
117 
118 void ad_print_statistics(void);
119 
120 acpi_status ad_find_dsdt(u8 **dsdt_ptr, u32 *dsdt_length);
121 
122 void ad_dump_tables(void);
123 
124 acpi_status ad_get_local_tables(void);
125 
126 acpi_status
127 ad_parse_table(struct acpi_table_header *table,
128 	       acpi_owner_id * owner_id, u8 load_table, u8 external);
129 
130 acpi_status ad_display_tables(char *filename, struct acpi_table_header *table);
131 
132 acpi_status ad_display_statistics(void);
133 
134 /*
135  * adwalk
136  */
137 void
138 acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root,
139 				  struct acpi_namespace_node *namespace_root,
140 				  acpi_owner_id owner_id);
141 
142 void acpi_dm_dump_tree(union acpi_parse_object *origin);
143 
144 void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
145 
146 void
147 acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root,
148 			      struct acpi_namespace_node *namespace_root,
149 			      acpi_owner_id owner_id);
150 
151 void
152 acpi_dm_convert_resource_indexes(union acpi_parse_object *parse_tree_root,
153 				 struct acpi_namespace_node *namespace_root);
154 
155 /*
156  * adfile
157  */
158 acpi_status ad_initialize(void);
159 
160 char *fl_generate_filename(char *input_filename, char *suffix);
161 
162 acpi_status
163 fl_split_input_pathname(char *input_path,
164 			char **out_directory_path, char **out_filename);
165 
166 char *ad_generate_filename(char *prefix, char *table_id);
167 
168 void
169 ad_write_table(struct acpi_table_header *table,
170 	       u32 length, char *table_name, char *oem_table_id);
171 #endif
172 
173 #endif				/* _ACAPPS */
174