Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: acparser.h - AML Parser subcomponent prototypes and defines |
| 5 | * |
Bob Moore | da6f832 | 2018-01-04 10:06:38 -0800 | [diff] [blame] | 6 | * Copyright (C) 2000 - 2018, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame^] | 8 | *****************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #ifndef __ACPARSER_H__ |
| 11 | #define __ACPARSER_H__ |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #define OP_HAS_RETURN_VALUE 1 |
| 14 | |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 15 | /* Variable number of arguments. This field must be 32 bits */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 17 | #define ACPI_VAR_ARGS ACPI_UINT32_MAX |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #define ACPI_PARSE_DELETE_TREE 0x0001 |
| 20 | #define ACPI_PARSE_NO_TREE_DELETE 0x0000 |
| 21 | #define ACPI_PARSE_TREE_MASK 0x0001 |
| 22 | |
| 23 | #define ACPI_PARSE_LOAD_PASS1 0x0010 |
| 24 | #define ACPI_PARSE_LOAD_PASS2 0x0020 |
| 25 | #define ACPI_PARSE_EXECUTE 0x0030 |
| 26 | #define ACPI_PARSE_MODE_MASK 0x0030 |
| 27 | |
| 28 | #define ACPI_PARSE_DEFERRED_OP 0x0100 |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 29 | #define ACPI_PARSE_DISASSEMBLE 0x0200 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Lin Ming | 7f0c826 | 2009-08-13 14:03:15 +0800 | [diff] [blame] | 31 | #define ACPI_PARSE_MODULE_LEVEL 0x0400 |
| 32 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 33 | /****************************************************************************** |
| 34 | * |
| 35 | * Parser interfaces |
| 36 | * |
| 37 | *****************************************************************************/ |
| 38 | |
Bob Moore | b0e01c7 | 2015-05-21 10:30:31 +0800 | [diff] [blame] | 39 | extern const u8 acpi_gbl_short_op_index[]; |
| 40 | extern const u8 acpi_gbl_long_op_index[]; |
| 41 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 42 | /* |
| 43 | * psxface - Parser external interfaces |
| 44 | */ |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 45 | acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Lv Zheng | de56ba9 | 2016-09-07 14:06:54 +0800 | [diff] [blame] | 47 | acpi_status acpi_ps_execute_table(struct acpi_evaluate_info *info); |
| 48 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 49 | /* |
| 50 | * psargs - Parse AML opcode arguments |
| 51 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 54 | char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 57 | acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, |
| 58 | u32 arg_type, union acpi_parse_object *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 61 | acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, |
| 62 | struct acpi_parse_state *parser_state, |
Bob Moore | 89438f9 | 2015-12-29 14:00:07 +0800 | [diff] [blame] | 63 | union acpi_parse_object *arg, |
| 64 | u8 possible_method_call); |
| 65 | |
| 66 | /* Values for u8 above */ |
| 67 | |
| 68 | #define ACPI_NOT_METHOD_CALL FALSE |
| 69 | #define ACPI_POSSIBLE_METHOD_CALL TRUE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 72 | acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, |
| 73 | struct acpi_parse_state *parser_state, |
| 74 | u32 arg_type, union acpi_parse_object **return_arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 76 | /* |
| 77 | * psfind |
| 78 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 79 | union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope, |
| 80 | u32 name, u32 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 84 | /* |
Bob Moore | 42f8fb7 | 2013-01-11 13:08:51 +0100 | [diff] [blame] | 85 | * psobject - support for parse object processing |
| 86 | */ |
| 87 | acpi_status |
| 88 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, |
| 89 | u8 *aml_op_start, |
| 90 | union acpi_parse_object *unnamed_op, |
| 91 | union acpi_parse_object **op); |
| 92 | |
| 93 | acpi_status |
| 94 | acpi_ps_create_op(struct acpi_walk_state *walk_state, |
| 95 | u8 *aml_op_start, union acpi_parse_object **new_op); |
| 96 | |
| 97 | acpi_status |
| 98 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, |
| 99 | union acpi_parse_object **op, acpi_status status); |
| 100 | |
| 101 | acpi_status |
| 102 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, |
| 103 | union acpi_parse_object *op, acpi_status status); |
| 104 | |
| 105 | /* |
| 106 | * psopinfo - AML Opcode information |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 107 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 108 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
Bob Moore | 0dfaaa3 | 2016-03-24 09:40:40 +0800 | [diff] [blame] | 110 | const char *acpi_ps_get_opcode_name(u16 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Bob Moore | 4e3156b | 2008-04-10 19:06:37 +0400 | [diff] [blame] | 112 | u8 acpi_ps_get_argument_count(u32 op_type); |
| 113 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 114 | /* |
| 115 | * psparse - top level parsing routines |
| 116 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | u32 acpi_ps_get_opcode_size(u32 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | u16 acpi_ps_peek_opcode(struct acpi_parse_state *state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 123 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 124 | acpi_ps_complete_this_op(struct acpi_walk_state *walk_state, |
| 125 | union acpi_parse_object *op); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 126 | |
| 127 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 128 | acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, |
| 129 | union acpi_parse_object *op, |
| 130 | acpi_status callback_status); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 131 | |
| 132 | /* |
| 133 | * psloop - main parse loop |
| 134 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 135 | acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 137 | /* |
| 138 | * psscope - Scope stack management routines |
| 139 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 141 | acpi_ps_init_scope(struct acpi_parse_state *parser_state, |
| 142 | union acpi_parse_object *root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 144 | union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state |
| 145 | *state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 147 | u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
| 149 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 150 | acpi_ps_pop_scope(struct acpi_parse_state *parser_state, |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 151 | union acpi_parse_object **op, u32 *arg_list, u32 *arg_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 154 | acpi_ps_push_scope(struct acpi_parse_state *parser_state, |
| 155 | union acpi_parse_object *op, |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 156 | u32 remaining_args, u32 arg_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | void acpi_ps_cleanup_scope(struct acpi_parse_state *state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 160 | /* |
| 161 | * pstree - parse tree manipulation routines |
| 162 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 164 | acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 166 | union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope, |
| 167 | char *path, u16 opcode, u32 create); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 169 | union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin, |
| 172 | union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 174 | /* |
| 175 | * pswalk - parse tree walk routines |
| 176 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 178 | acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op, |
| 179 | union acpi_parse_object *end_op, |
| 180 | union acpi_operand_object *mth_desc, |
| 181 | struct acpi_namespace_node *start_node, |
| 182 | union acpi_operand_object **params, |
| 183 | union acpi_operand_object **caller_return_desc, |
| 184 | acpi_owner_id owner_id, |
| 185 | acpi_parse_downwards descending_callback, |
| 186 | acpi_parse_upwards ascending_callback); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
| 188 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 189 | acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state, |
| 190 | union acpi_parse_object *op, |
| 191 | acpi_parse_upwards ascending_callback); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 195 | void acpi_ps_delete_parse_tree(union acpi_parse_object *root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 197 | /* |
| 198 | * psutils - parser utilities |
| 199 | */ |
Lv Zheng | 62eb935 | 2015-07-23 12:52:24 +0800 | [diff] [blame] | 200 | union acpi_parse_object *acpi_ps_create_scope_op(u8 *aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 202 | void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
Lv Zheng | 62eb935 | 2015-07-23 12:52:24 +0800 | [diff] [blame] | 204 | union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 206 | void acpi_ps_free_op(union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 208 | u8 acpi_ps_is_leading_char(u32 c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 210 | u32 acpi_ps_get_name(union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 212 | void acpi_ps_set_name(union acpi_parse_object *op, u32 name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 214 | /* |
| 215 | * psdump - display parser tree |
| 216 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | u32 |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 218 | acpi_ps_sprint_path(char *buffer_start, |
| 219 | u32 buffer_size, union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | u32 |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 222 | acpi_ps_sprint_op(char *buffer_start, |
| 223 | u32 buffer_size, union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 225 | void acpi_ps_show(union acpi_parse_object *op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 227 | #endif /* __ACPARSER_H__ */ |