xref: /openbmc/linux/drivers/acpi/acpica/acapps.h (revision 3a83e4e6)
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /******************************************************************************
3  *
4  * Module Name: acapps - common include for ACPI applications/tools
5  *
6  * Copyright (C) 2000 - 2020, Intel Corp.
7  *
8  *****************************************************************************/
9 
10 #ifndef _ACAPPS
11 #define _ACAPPS
12 
13 #ifdef ACPI_USE_STANDARD_HEADERS
14 #include <sys/stat.h>
15 #endif				/* ACPI_USE_STANDARD_HEADERS */
16 
17 /* Common info for tool signons */
18 
19 #define ACPICA_NAME                 "Intel ACPI Component Architecture"
20 #define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2020 Intel Corporation"
21 
22 #if ACPI_MACHINE_WIDTH == 64
23 #define ACPI_WIDTH          " (64-bit version)"
24 
25 #elif ACPI_MACHINE_WIDTH == 32
26 #define ACPI_WIDTH          " (32-bit version)"
27 
28 #else
29 #error unknown ACPI_MACHINE_WIDTH
30 #define ACPI_WIDTH          " (unknown bit width, not 32 or 64)"
31 
32 #endif
33 
34 /* Macros for signons and file headers */
35 
36 #define ACPI_COMMON_SIGNON(utility_name) \
37 	"\n%s\n%s version %8.8X\n%s\n\n", \
38 	ACPICA_NAME, \
39 	utility_name, ((u32) ACPI_CA_VERSION), \
40 	ACPICA_COPYRIGHT
41 
42 #define ACPI_COMMON_HEADER(utility_name, prefix) \
43 	"%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
44 	prefix, ACPICA_NAME, \
45 	prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
46 	prefix, ACPICA_COPYRIGHT, \
47 	prefix
48 
49 #define ACPI_COMMON_BUILD_TIME \
50 	"Build date/time: %s %s\n", __DATE__, __TIME__
51 
52 /* Macros for usage messages */
53 
54 #define ACPI_USAGE_HEADER(usage) \
55 	printf ("Usage: %s\nOptions:\n", usage);
56 
57 #define ACPI_USAGE_TEXT(description) \
58 	printf (description);
59 
60 #define ACPI_OPTION(name, description) \
61 	printf ("  %-20s%s\n", name, description);
62 
63 /* Check for unexpected exceptions */
64 
65 #define ACPI_CHECK_STATUS(name, status, expected) \
66 	if (status != expected) \
67 	{ \
68 		acpi_os_printf ("Unexpected %s from %s (%s-%d)\n", \
69 			acpi_format_exception (status), #name, _acpi_module_name, __LINE__); \
70 	}
71 
72 /* Check for unexpected non-AE_OK errors */
73 
74 #define ACPI_CHECK_OK(name, status)   ACPI_CHECK_STATUS (name, status, AE_OK);
75 
76 #define FILE_SUFFIX_DISASSEMBLY     "dsl"
77 #define FILE_SUFFIX_BINARY_TABLE    ".dat"	/* Needs the dot */
78 
79 /* acfileio */
80 
81 acpi_status
82 ac_get_all_tables_from_file(char *filename,
83 			    u8 get_only_aml_tables,
84 			    struct acpi_new_table_desc **return_list_head);
85 
86 void ac_delete_table_list(struct acpi_new_table_desc *list_head);
87 
88 u8 ac_is_file_binary(FILE * file);
89 
90 acpi_status ac_validate_table_header(FILE * file, long table_offset);
91 
92 /* Values for get_only_aml_tables */
93 
94 #define ACPI_GET_ONLY_AML_TABLES    TRUE
95 #define ACPI_GET_ALL_TABLES         FALSE
96 
97 /*
98  * getopt
99  */
100 int acpi_getopt(int argc, char **argv, char *opts);
101 
102 int acpi_getopt_argument(int argc, char **argv);
103 
104 extern int acpi_gbl_optind;
105 extern int acpi_gbl_opterr;
106 extern int acpi_gbl_sub_opt_char;
107 extern char *acpi_gbl_optarg;
108 
109 /*
110  * cmfsize - Common get file size function
111  */
112 u32 cm_get_file_size(ACPI_FILE file);
113 
114 /*
115  * adwalk
116  */
117 void
118 acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root,
119 				  struct acpi_namespace_node *namespace_root,
120 				  acpi_owner_id owner_id);
121 
122 void acpi_dm_dump_tree(union acpi_parse_object *origin);
123 
124 void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
125 
126 void
127 acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root,
128 			      struct acpi_namespace_node *namespace_root,
129 			      acpi_owner_id owner_id);
130 
131 void
132 acpi_dm_convert_parse_objects(union acpi_parse_object *parse_tree_root,
133 			      struct acpi_namespace_node *namespace_root);
134 
135 /*
136  * adfile
137  */
138 acpi_status ad_initialize(void);
139 
140 char *fl_generate_filename(char *input_filename, char *suffix);
141 
142 acpi_status
143 fl_split_input_pathname(char *input_path,
144 			char **out_directory_path, char **out_filename);
145 
146 char *fl_get_file_basename(char *file_pathname);
147 
148 char *ad_generate_filename(char *prefix, char *table_id);
149 
150 void
151 ad_write_table(struct acpi_table_header *table,
152 	       u32 length, char *table_name, char *oem_table_id);
153 
154 #endif				/* _ACAPPS */
155