Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /******************************************************************************
0003  *
0004  * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
0005  *
0006  * Copyright (C) 2000 - 2022, Intel Corp.
0007  *
0008  *****************************************************************************/
0009 
0010 #ifndef __ACPARSER_H__
0011 #define __ACPARSER_H__
0012 
0013 #define OP_HAS_RETURN_VALUE             1
0014 
0015 /* Variable number of arguments. This field must be 32 bits */
0016 
0017 #define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
0018 
0019 #define ACPI_PARSE_DELETE_TREE          0x0001
0020 #define ACPI_PARSE_NO_TREE_DELETE       0x0000
0021 #define ACPI_PARSE_TREE_MASK            0x0001
0022 
0023 #define ACPI_PARSE_LOAD_PASS1           0x0010
0024 #define ACPI_PARSE_LOAD_PASS2           0x0020
0025 #define ACPI_PARSE_EXECUTE              0x0030
0026 #define ACPI_PARSE_MODE_MASK            0x0030
0027 
0028 #define ACPI_PARSE_DEFERRED_OP          0x0100
0029 #define ACPI_PARSE_DISASSEMBLE          0x0200
0030 
0031 #define ACPI_PARSE_MODULE_LEVEL         0x0400
0032 
0033 /******************************************************************************
0034  *
0035  * Parser interfaces
0036  *
0037  *****************************************************************************/
0038 
0039 extern const u8 acpi_gbl_short_op_index[];
0040 extern const u8 acpi_gbl_long_op_index[];
0041 
0042 /*
0043  * psxface - Parser external interfaces
0044  */
0045 acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info);
0046 
0047 acpi_status acpi_ps_execute_table(struct acpi_evaluate_info *info);
0048 
0049 /*
0050  * psargs - Parse AML opcode arguments
0051  */
0052 u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state);
0053 
0054 char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state);
0055 
0056 void
0057 acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
0058                 u32 arg_type, union acpi_parse_object *arg);
0059 
0060 acpi_status
0061 acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
0062               struct acpi_parse_state *parser_state,
0063               union acpi_parse_object *arg,
0064               u8 possible_method_call);
0065 
0066 /* Values for u8 above */
0067 
0068 #define ACPI_NOT_METHOD_CALL            FALSE
0069 #define ACPI_POSSIBLE_METHOD_CALL       TRUE
0070 
0071 acpi_status
0072 acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
0073              struct acpi_parse_state *parser_state,
0074              u32 arg_type, union acpi_parse_object **return_arg);
0075 
0076 /*
0077  * psfind
0078  */
0079 union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
0080                        u32 name, u32 opcode);
0081 
0082 union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
0083 
0084 /*
0085  * psobject - support for parse object processing
0086  */
0087 acpi_status
0088 acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
0089                u8 *aml_op_start,
0090                union acpi_parse_object *unnamed_op,
0091                union acpi_parse_object **op);
0092 
0093 acpi_status
0094 acpi_ps_create_op(struct acpi_walk_state *walk_state,
0095           u8 *aml_op_start, union acpi_parse_object **new_op);
0096 
0097 acpi_status
0098 acpi_ps_complete_op(struct acpi_walk_state *walk_state,
0099             union acpi_parse_object **op, acpi_status status);
0100 
0101 acpi_status
0102 acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
0103               union acpi_parse_object *op, acpi_status status);
0104 
0105 /*
0106  * psopinfo - AML Opcode information
0107  */
0108 const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
0109 
0110 const char *acpi_ps_get_opcode_name(u16 opcode);
0111 
0112 u8 acpi_ps_get_argument_count(u32 op_type);
0113 
0114 /*
0115  * psparse - top level parsing routines
0116  */
0117 acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state);
0118 
0119 u32 acpi_ps_get_opcode_size(u32 opcode);
0120 
0121 u16 acpi_ps_peek_opcode(struct acpi_parse_state *state);
0122 
0123 acpi_status
0124 acpi_ps_complete_this_op(struct acpi_walk_state *walk_state,
0125              union acpi_parse_object *op);
0126 
0127 acpi_status
0128 acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
0129              union acpi_parse_object *op,
0130              acpi_status callback_status);
0131 
0132 /*
0133  * psloop - main parse loop
0134  */
0135 acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state);
0136 
0137 /*
0138  * psscope - Scope stack management routines
0139  */
0140 acpi_status
0141 acpi_ps_init_scope(struct acpi_parse_state *parser_state,
0142            union acpi_parse_object *root);
0143 
0144 union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
0145                           *state);
0146 
0147 u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
0148 
0149 void
0150 acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
0151           union acpi_parse_object **op, u32 *arg_list, u32 *arg_count);
0152 
0153 acpi_status
0154 acpi_ps_push_scope(struct acpi_parse_state *parser_state,
0155            union acpi_parse_object *op,
0156            u32 remaining_args, u32 arg_count);
0157 
0158 void acpi_ps_cleanup_scope(struct acpi_parse_state *state);
0159 
0160 /*
0161  * pstree - parse tree manipulation routines
0162  */
0163 void
0164 acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg);
0165 
0166 union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope,
0167                       char *path, u16 opcode, u32 create);
0168 
0169 union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn);
0170 
0171 union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
0172                         union acpi_parse_object *op);
0173 
0174 /*
0175  * pswalk - parse tree walk routines
0176  */
0177 acpi_status
0178 acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op,
0179             union acpi_parse_object *end_op,
0180             union acpi_operand_object *mth_desc,
0181             struct acpi_namespace_node *start_node,
0182             union acpi_operand_object **params,
0183             union acpi_operand_object **caller_return_desc,
0184             acpi_owner_id owner_id,
0185             acpi_parse_downwards descending_callback,
0186             acpi_parse_upwards ascending_callback);
0187 
0188 acpi_status
0189 acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state,
0190              union acpi_parse_object *op,
0191              acpi_parse_upwards ascending_callback);
0192 
0193 acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state);
0194 
0195 void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
0196 
0197 /*
0198  * psutils - parser utilities
0199  */
0200 union acpi_parse_object *acpi_ps_create_scope_op(u8 *aml);
0201 
0202 void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
0203 
0204 union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml);
0205 
0206 void acpi_ps_free_op(union acpi_parse_object *op);
0207 
0208 u8 acpi_ps_is_leading_char(u32 c);
0209 
0210 u32 acpi_ps_get_name(union acpi_parse_object *op);
0211 
0212 void acpi_ps_set_name(union acpi_parse_object *op, u32 name);
0213 
0214 /*
0215  * psdump - display parser tree
0216  */
0217 u32
0218 acpi_ps_sprint_path(char *buffer_start,
0219             u32 buffer_size, union acpi_parse_object *op);
0220 
0221 u32
0222 acpi_ps_sprint_op(char *buffer_start,
0223           u32 buffer_size, union acpi_parse_object *op);
0224 
0225 void acpi_ps_show(union acpi_parse_object *op);
0226 
0227 #endif              /* __ACPARSER_H__ */