blob: a2a85122fafeeb1bf6ec3813fa845cfa8da63a24 [file] [log] [blame]
Erik Schmauss95857632018-03-14 16:13:07 -07001/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
Lv Zheng506f57dd62014-04-04 12:39:42 +08002/******************************************************************************
3 *
4 * Module Name: acapps - common include for ACPI applications/tools
5 *
Bob Mooreda6f8322018-01-04 10:06:38 -08006 * Copyright (C) 2000 - 2018, Intel Corp.
Lv Zheng506f57dd62014-04-04 12:39:42 +08007 *
Erik Schmauss95857632018-03-14 16:13:07 -07008 *****************************************************************************/
Lv Zheng506f57dd62014-04-04 12:39:42 +08009
10#ifndef _ACAPPS
11#define _ACAPPS
12
Lv Zhenge323c022016-08-04 16:44:59 +080013#ifdef ACPI_USE_STANDARD_HEADERS
14#include <sys/stat.h>
15#endif /* ACPI_USE_STANDARD_HEADERS */
16
Lv Zheng506f57dd62014-04-04 12:39:42 +080017/* Common info for tool signons */
18
19#define ACPICA_NAME "Intel ACPI Component Architecture"
Bob Mooreda6f8322018-01-04 10:06:38 -080020#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2018 Intel Corporation"
Lv Zheng506f57dd62014-04-04 12:39:42 +080021
22#if ACPI_MACHINE_WIDTH == 64
Bob Moore892411d2017-02-08 11:00:15 +080023#define ACPI_WIDTH " (64-bit version)"
Lv Zheng506f57dd62014-04-04 12:39:42 +080024
25#elif ACPI_MACHINE_WIDTH == 32
Bob Moore892411d2017-02-08 11:00:15 +080026#define ACPI_WIDTH " (32-bit version)"
Lv Zheng506f57dd62014-04-04 12:39:42 +080027
28#else
29#error unknown ACPI_MACHINE_WIDTH
Bob Moore892411d2017-02-08 11:00:15 +080030#define ACPI_WIDTH " (unknown bit width, not 32 or 64)"
Lv Zheng506f57dd62014-04-04 12:39:42 +080031
32#endif
33
34/* Macros for signons and file headers */
35
36#define ACPI_COMMON_SIGNON(utility_name) \
Bob Moore892411d2017-02-08 11:00:15 +080037 "\n%s\n%s version %8.8X\n%s\n\n", \
Lv Zheng506f57dd62014-04-04 12:39:42 +080038 ACPICA_NAME, \
Bob Moore892411d2017-02-08 11:00:15 +080039 utility_name, ((u32) ACPI_CA_VERSION), \
Lv Zheng506f57dd62014-04-04 12:39:42 +080040 ACPICA_COPYRIGHT
41
42#define ACPI_COMMON_HEADER(utility_name, prefix) \
Rasmus Villemoes1797d372015-04-13 11:49:18 +080043 "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
Lv Zheng506f57dd62014-04-04 12:39:42 +080044 prefix, ACPICA_NAME, \
Rasmus Villemoes1797d372015-04-13 11:49:18 +080045 prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, \
Lv Zheng506f57dd62014-04-04 12:39:42 +080046 prefix, ACPICA_COPYRIGHT, \
47 prefix
48
Bob Moore90adf772017-11-17 15:40:20 -080049#define ACPI_COMMON_BUILD_TIME \
50 "Build date/time: %s %s\n", __DATE__, __TIME__
51
Lv Zheng506f57dd62014-04-04 12:39:42 +080052/* Macros for usage messages */
53
54#define ACPI_USAGE_HEADER(usage) \
Lv Zheng911a9b82016-08-04 16:45:22 +080055 printf ("Usage: %s\nOptions:\n", usage);
Lv Zhengd9cf1472014-07-08 10:07:13 +080056
57#define ACPI_USAGE_TEXT(description) \
Lv Zheng911a9b82016-08-04 16:45:22 +080058 printf (description);
Lv Zheng506f57dd62014-04-04 12:39:42 +080059
60#define ACPI_OPTION(name, description) \
Lv Zheng911a9b82016-08-04 16:45:22 +080061 printf (" %-20s%s\n", name, description);
Lv Zheng506f57dd62014-04-04 12:39:42 +080062
Bob Moore3727ec22015-12-29 13:56:46 +080063/* 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
Lv Zheng506f57dd62014-04-04 12:39:42 +080076#define FILE_SUFFIX_DISASSEMBLY "dsl"
Bob Moore842e71332015-10-19 10:25:04 +080077#define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */
Lv Zheng506f57dd62014-04-04 12:39:42 +080078
Bob Moore2ba73792015-12-29 13:54:58 +080079/* acfileio */
80
81acpi_status
Bob Moore395ec732015-12-29 13:55:05 +080082ac_get_all_tables_from_file(char *filename,
83 u8 get_only_aml_tables,
84 struct acpi_new_table_desc **return_list_head);
85
Erik Schmaussff7993a2017-07-10 15:22:56 +080086void ac_delete_table_list(struct acpi_new_table_desc *list_head);
87
Bob Moore395ec732015-12-29 13:55:05 +080088u8 ac_is_file_binary(FILE * file);
89
90acpi_status ac_validate_table_header(FILE * file, long table_offset);
Bob Moore2ba73792015-12-29 13:54:58 +080091
92/* Values for get_only_aml_tables */
93
94#define ACPI_GET_ONLY_AML_TABLES TRUE
95#define ACPI_GET_ALL_TABLES FALSE
96
Lv Zheng506f57dd62014-04-04 12:39:42 +080097/*
98 * getopt
99 */
100int acpi_getopt(int argc, char **argv, char *opts);
101
102int acpi_getopt_argument(int argc, char **argv);
103
104extern int acpi_gbl_optind;
105extern int acpi_gbl_opterr;
106extern int acpi_gbl_sub_opt_char;
107extern char *acpi_gbl_optarg;
108
109/*
110 * cmfsize - Common get file size function
111 */
Lv Zheng3c9349c2014-07-08 10:07:19 +0800112u32 cm_get_file_size(ACPI_FILE file);
Lv Zheng506f57dd62014-04-04 12:39:42 +0800113
Lv Zheng506f57dd62014-04-04 12:39:42 +0800114/*
115 * adwalk
116 */
117void
118acpi_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
122void acpi_dm_dump_tree(union acpi_parse_object *origin);
123
124void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
125
126void
127acpi_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
131void
David E. Boxa86c8562017-06-05 16:38:53 +0800132acpi_dm_convert_parse_objects(union acpi_parse_object *parse_tree_root,
133 struct acpi_namespace_node *namespace_root);
Lv Zheng506f57dd62014-04-04 12:39:42 +0800134
135/*
136 * adfile
137 */
138acpi_status ad_initialize(void);
139
140char *fl_generate_filename(char *input_filename, char *suffix);
141
142acpi_status
143fl_split_input_pathname(char *input_path,
144 char **out_directory_path, char **out_filename);
145
146char *ad_generate_filename(char *prefix, char *table_id);
147
148void
149ad_write_table(struct acpi_table_header *table,
150 u32 length, char *table_name, char *oem_table_id);
Lv Zheng506f57dd62014-04-04 12:39:42 +0800151
152#endif /* _ACAPPS */