162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 262306a36Sopenharmony_ci/****************************************************************************** 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Name: amlcode.h - Definitions for AML, as included in "definition blocks" 562306a36Sopenharmony_ci * Declarations and definitions contained herein are derived 662306a36Sopenharmony_ci * directly from the ACPI specification. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright (C) 2000 - 2023, Intel Corp. 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci *****************************************************************************/ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef __AMLCODE_H__ 1362306a36Sopenharmony_ci#define __AMLCODE_H__ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* primary opcodes */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#define AML_ZERO_OP (u16) 0x00 1862306a36Sopenharmony_ci#define AML_ONE_OP (u16) 0x01 1962306a36Sopenharmony_ci#define AML_ALIAS_OP (u16) 0x06 2062306a36Sopenharmony_ci#define AML_NAME_OP (u16) 0x08 2162306a36Sopenharmony_ci#define AML_BYTE_OP (u16) 0x0a 2262306a36Sopenharmony_ci#define AML_WORD_OP (u16) 0x0b 2362306a36Sopenharmony_ci#define AML_DWORD_OP (u16) 0x0c 2462306a36Sopenharmony_ci#define AML_STRING_OP (u16) 0x0d 2562306a36Sopenharmony_ci#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */ 2662306a36Sopenharmony_ci#define AML_SCOPE_OP (u16) 0x10 2762306a36Sopenharmony_ci#define AML_BUFFER_OP (u16) 0x11 2862306a36Sopenharmony_ci#define AML_PACKAGE_OP (u16) 0x12 2962306a36Sopenharmony_ci#define AML_VARIABLE_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */ 3062306a36Sopenharmony_ci#define AML_METHOD_OP (u16) 0x14 3162306a36Sopenharmony_ci#define AML_EXTERNAL_OP (u16) 0x15 /* ACPI 6.0 */ 3262306a36Sopenharmony_ci#define AML_DUAL_NAME_PREFIX (u16) 0x2e 3362306a36Sopenharmony_ci#define AML_MULTI_NAME_PREFIX (u16) 0x2f 3462306a36Sopenharmony_ci#define AML_EXTENDED_PREFIX (u16) 0x5b 3562306a36Sopenharmony_ci#define AML_ROOT_PREFIX (u16) 0x5c 3662306a36Sopenharmony_ci#define AML_PARENT_PREFIX (u16) 0x5e 3762306a36Sopenharmony_ci#define AML_FIRST_LOCAL_OP (u16) 0x60 /* Used for Local op # calculations */ 3862306a36Sopenharmony_ci#define AML_LOCAL0 (u16) 0x60 3962306a36Sopenharmony_ci#define AML_LOCAL1 (u16) 0x61 4062306a36Sopenharmony_ci#define AML_LOCAL2 (u16) 0x62 4162306a36Sopenharmony_ci#define AML_LOCAL3 (u16) 0x63 4262306a36Sopenharmony_ci#define AML_LOCAL4 (u16) 0x64 4362306a36Sopenharmony_ci#define AML_LOCAL5 (u16) 0x65 4462306a36Sopenharmony_ci#define AML_LOCAL6 (u16) 0x66 4562306a36Sopenharmony_ci#define AML_LOCAL7 (u16) 0x67 4662306a36Sopenharmony_ci#define AML_FIRST_ARG_OP (u16) 0x68 /* Used for Arg op # calculations */ 4762306a36Sopenharmony_ci#define AML_ARG0 (u16) 0x68 4862306a36Sopenharmony_ci#define AML_ARG1 (u16) 0x69 4962306a36Sopenharmony_ci#define AML_ARG2 (u16) 0x6a 5062306a36Sopenharmony_ci#define AML_ARG3 (u16) 0x6b 5162306a36Sopenharmony_ci#define AML_ARG4 (u16) 0x6c 5262306a36Sopenharmony_ci#define AML_ARG5 (u16) 0x6d 5362306a36Sopenharmony_ci#define AML_ARG6 (u16) 0x6e 5462306a36Sopenharmony_ci#define AML_STORE_OP (u16) 0x70 5562306a36Sopenharmony_ci#define AML_REF_OF_OP (u16) 0x71 5662306a36Sopenharmony_ci#define AML_ADD_OP (u16) 0x72 5762306a36Sopenharmony_ci#define AML_CONCATENATE_OP (u16) 0x73 5862306a36Sopenharmony_ci#define AML_SUBTRACT_OP (u16) 0x74 5962306a36Sopenharmony_ci#define AML_INCREMENT_OP (u16) 0x75 6062306a36Sopenharmony_ci#define AML_DECREMENT_OP (u16) 0x76 6162306a36Sopenharmony_ci#define AML_MULTIPLY_OP (u16) 0x77 6262306a36Sopenharmony_ci#define AML_DIVIDE_OP (u16) 0x78 6362306a36Sopenharmony_ci#define AML_SHIFT_LEFT_OP (u16) 0x79 6462306a36Sopenharmony_ci#define AML_SHIFT_RIGHT_OP (u16) 0x7a 6562306a36Sopenharmony_ci#define AML_BIT_AND_OP (u16) 0x7b 6662306a36Sopenharmony_ci#define AML_BIT_NAND_OP (u16) 0x7c 6762306a36Sopenharmony_ci#define AML_BIT_OR_OP (u16) 0x7d 6862306a36Sopenharmony_ci#define AML_BIT_NOR_OP (u16) 0x7e 6962306a36Sopenharmony_ci#define AML_BIT_XOR_OP (u16) 0x7f 7062306a36Sopenharmony_ci#define AML_BIT_NOT_OP (u16) 0x80 7162306a36Sopenharmony_ci#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81 7262306a36Sopenharmony_ci#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82 7362306a36Sopenharmony_ci#define AML_DEREF_OF_OP (u16) 0x83 7462306a36Sopenharmony_ci#define AML_CONCATENATE_TEMPLATE_OP (u16) 0x84 /* ACPI 2.0 */ 7562306a36Sopenharmony_ci#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */ 7662306a36Sopenharmony_ci#define AML_NOTIFY_OP (u16) 0x86 7762306a36Sopenharmony_ci#define AML_SIZE_OF_OP (u16) 0x87 7862306a36Sopenharmony_ci#define AML_INDEX_OP (u16) 0x88 7962306a36Sopenharmony_ci#define AML_MATCH_OP (u16) 0x89 8062306a36Sopenharmony_ci#define AML_CREATE_DWORD_FIELD_OP (u16) 0x8a 8162306a36Sopenharmony_ci#define AML_CREATE_WORD_FIELD_OP (u16) 0x8b 8262306a36Sopenharmony_ci#define AML_CREATE_BYTE_FIELD_OP (u16) 0x8c 8362306a36Sopenharmony_ci#define AML_CREATE_BIT_FIELD_OP (u16) 0x8d 8462306a36Sopenharmony_ci#define AML_OBJECT_TYPE_OP (u16) 0x8e 8562306a36Sopenharmony_ci#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */ 8662306a36Sopenharmony_ci#define AML_LOGICAL_AND_OP (u16) 0x90 8762306a36Sopenharmony_ci#define AML_LOGICAL_OR_OP (u16) 0x91 8862306a36Sopenharmony_ci#define AML_LOGICAL_NOT_OP (u16) 0x92 8962306a36Sopenharmony_ci#define AML_LOGICAL_EQUAL_OP (u16) 0x93 9062306a36Sopenharmony_ci#define AML_LOGICAL_GREATER_OP (u16) 0x94 9162306a36Sopenharmony_ci#define AML_LOGICAL_LESS_OP (u16) 0x95 9262306a36Sopenharmony_ci#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */ 9362306a36Sopenharmony_ci#define AML_TO_DECIMAL_STRING_OP (u16) 0x97 /* ACPI 2.0 */ 9462306a36Sopenharmony_ci#define AML_TO_HEX_STRING_OP (u16) 0x98 /* ACPI 2.0 */ 9562306a36Sopenharmony_ci#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */ 9662306a36Sopenharmony_ci#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */ 9762306a36Sopenharmony_ci#define AML_COPY_OBJECT_OP (u16) 0x9d /* ACPI 2.0 */ 9862306a36Sopenharmony_ci#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */ 9962306a36Sopenharmony_ci#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */ 10062306a36Sopenharmony_ci#define AML_IF_OP (u16) 0xa0 10162306a36Sopenharmony_ci#define AML_ELSE_OP (u16) 0xa1 10262306a36Sopenharmony_ci#define AML_WHILE_OP (u16) 0xa2 10362306a36Sopenharmony_ci#define AML_NOOP_OP (u16) 0xa3 10462306a36Sopenharmony_ci#define AML_RETURN_OP (u16) 0xa4 10562306a36Sopenharmony_ci#define AML_BREAK_OP (u16) 0xa5 10662306a36Sopenharmony_ci#define AML_COMMENT_OP (u16) 0xa9 10762306a36Sopenharmony_ci#define AML_BREAKPOINT_OP (u16) 0xcc 10862306a36Sopenharmony_ci#define AML_ONES_OP (u16) 0xff 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* 11162306a36Sopenharmony_ci * Combination opcodes (actually two one-byte opcodes) 11262306a36Sopenharmony_ci * Used by the disassembler and iASL compiler 11362306a36Sopenharmony_ci */ 11462306a36Sopenharmony_ci#define AML_LOGICAL_GREATER_EQUAL_OP (u16) 0x9295 /* LNot (LLess) */ 11562306a36Sopenharmony_ci#define AML_LOGICAL_LESS_EQUAL_OP (u16) 0x9294 /* LNot (LGreater) */ 11662306a36Sopenharmony_ci#define AML_LOGICAL_NOT_EQUAL_OP (u16) 0x9293 /* LNot (LEqual) */ 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci/* Prefixed (2-byte) opcodes (with AML_EXTENDED_PREFIX) */ 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* Prefix for 2-byte opcodes */ 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#define AML_MUTEX_OP (u16) 0x5b01 12362306a36Sopenharmony_ci#define AML_EVENT_OP (u16) 0x5b02 12462306a36Sopenharmony_ci#define AML_SHIFT_RIGHT_BIT_OP (u16) 0x5b10 /* Obsolete, not in ACPI spec */ 12562306a36Sopenharmony_ci#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11 /* Obsolete, not in ACPI spec */ 12662306a36Sopenharmony_ci#define AML_CONDITIONAL_REF_OF_OP (u16) 0x5b12 12762306a36Sopenharmony_ci#define AML_CREATE_FIELD_OP (u16) 0x5b13 12862306a36Sopenharmony_ci#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */ 12962306a36Sopenharmony_ci#define AML_LOAD_OP (u16) 0x5b20 13062306a36Sopenharmony_ci#define AML_STALL_OP (u16) 0x5b21 13162306a36Sopenharmony_ci#define AML_SLEEP_OP (u16) 0x5b22 13262306a36Sopenharmony_ci#define AML_ACQUIRE_OP (u16) 0x5b23 13362306a36Sopenharmony_ci#define AML_SIGNAL_OP (u16) 0x5b24 13462306a36Sopenharmony_ci#define AML_WAIT_OP (u16) 0x5b25 13562306a36Sopenharmony_ci#define AML_RESET_OP (u16) 0x5b26 13662306a36Sopenharmony_ci#define AML_RELEASE_OP (u16) 0x5b27 13762306a36Sopenharmony_ci#define AML_FROM_BCD_OP (u16) 0x5b28 13862306a36Sopenharmony_ci#define AML_TO_BCD_OP (u16) 0x5b29 13962306a36Sopenharmony_ci#define AML_UNLOAD_OP (u16) 0x5b2a 14062306a36Sopenharmony_ci#define AML_REVISION_OP (u16) 0x5b30 14162306a36Sopenharmony_ci#define AML_DEBUG_OP (u16) 0x5b31 14262306a36Sopenharmony_ci#define AML_FATAL_OP (u16) 0x5b32 14362306a36Sopenharmony_ci#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */ 14462306a36Sopenharmony_ci#define AML_REGION_OP (u16) 0x5b80 14562306a36Sopenharmony_ci#define AML_FIELD_OP (u16) 0x5b81 14662306a36Sopenharmony_ci#define AML_DEVICE_OP (u16) 0x5b82 14762306a36Sopenharmony_ci#define AML_PROCESSOR_OP (u16) 0x5b83 14862306a36Sopenharmony_ci#define AML_POWER_RESOURCE_OP (u16) 0x5b84 14962306a36Sopenharmony_ci#define AML_THERMAL_ZONE_OP (u16) 0x5b85 15062306a36Sopenharmony_ci#define AML_INDEX_FIELD_OP (u16) 0x5b86 15162306a36Sopenharmony_ci#define AML_BANK_FIELD_OP (u16) 0x5b87 15262306a36Sopenharmony_ci#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */ 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci/* 15562306a36Sopenharmony_ci * Opcodes for "Field" operators 15662306a36Sopenharmony_ci */ 15762306a36Sopenharmony_ci#define AML_FIELD_OFFSET_OP (u8) 0x00 15862306a36Sopenharmony_ci#define AML_FIELD_ACCESS_OP (u8) 0x01 15962306a36Sopenharmony_ci#define AML_FIELD_CONNECTION_OP (u8) 0x02 /* ACPI 5.0 */ 16062306a36Sopenharmony_ci#define AML_FIELD_EXT_ACCESS_OP (u8) 0x03 /* ACPI 5.0 */ 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci/* 16362306a36Sopenharmony_ci * Internal opcodes 16462306a36Sopenharmony_ci * Use only "Unknown" AML opcodes, don't attempt to use 16562306a36Sopenharmony_ci * any valid ACPI ASCII values (A-Z, 0-9, '-') 16662306a36Sopenharmony_ci */ 16762306a36Sopenharmony_ci#define AML_INT_NAMEPATH_OP (u16) 0x002d 16862306a36Sopenharmony_ci#define AML_INT_NAMEDFIELD_OP (u16) 0x0030 16962306a36Sopenharmony_ci#define AML_INT_RESERVEDFIELD_OP (u16) 0x0031 17062306a36Sopenharmony_ci#define AML_INT_ACCESSFIELD_OP (u16) 0x0032 17162306a36Sopenharmony_ci#define AML_INT_BYTELIST_OP (u16) 0x0033 17262306a36Sopenharmony_ci#define AML_INT_METHODCALL_OP (u16) 0x0035 17362306a36Sopenharmony_ci#define AML_INT_RETURN_VALUE_OP (u16) 0x0036 17462306a36Sopenharmony_ci#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037 17562306a36Sopenharmony_ci#define AML_INT_CONNECTION_OP (u16) 0x0038 17662306a36Sopenharmony_ci#define AML_INT_EXTACCESSFIELD_OP (u16) 0x0039 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci#define ARG_NONE 0x0 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci/* 18162306a36Sopenharmony_ci * Argument types for the AML Parser 18262306a36Sopenharmony_ci * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments. 18362306a36Sopenharmony_ci * There can be up to 31 unique argument types 18462306a36Sopenharmony_ci * Zero is reserved as end-of-list indicator 18562306a36Sopenharmony_ci */ 18662306a36Sopenharmony_ci#define ARGP_BYTEDATA 0x01 18762306a36Sopenharmony_ci#define ARGP_BYTELIST 0x02 18862306a36Sopenharmony_ci#define ARGP_CHARLIST 0x03 18962306a36Sopenharmony_ci#define ARGP_DATAOBJ 0x04 19062306a36Sopenharmony_ci#define ARGP_DATAOBJLIST 0x05 19162306a36Sopenharmony_ci#define ARGP_DWORDDATA 0x06 19262306a36Sopenharmony_ci#define ARGP_FIELDLIST 0x07 19362306a36Sopenharmony_ci#define ARGP_NAME 0x08 19462306a36Sopenharmony_ci#define ARGP_NAMESTRING 0x09 19562306a36Sopenharmony_ci#define ARGP_OBJLIST 0x0A 19662306a36Sopenharmony_ci#define ARGP_PKGLENGTH 0x0B 19762306a36Sopenharmony_ci#define ARGP_SUPERNAME 0x0C 19862306a36Sopenharmony_ci#define ARGP_TARGET 0x0D 19962306a36Sopenharmony_ci#define ARGP_TERMARG 0x0E 20062306a36Sopenharmony_ci#define ARGP_TERMLIST 0x0F 20162306a36Sopenharmony_ci#define ARGP_WORDDATA 0x10 20262306a36Sopenharmony_ci#define ARGP_QWORDDATA 0x11 20362306a36Sopenharmony_ci#define ARGP_SIMPLENAME 0x12 /* name_string | local_term | arg_term */ 20462306a36Sopenharmony_ci#define ARGP_NAME_OR_REF 0x13 /* For object_type only */ 20562306a36Sopenharmony_ci#define ARGP_MAX 0x13 20662306a36Sopenharmony_ci#define ARGP_COMMENT 0x14 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci/* 20962306a36Sopenharmony_ci * Resolved argument types for the AML Interpreter 21062306a36Sopenharmony_ci * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments. 21162306a36Sopenharmony_ci * There can be up to 31 unique argument types (0 is end-of-arg-list indicator) 21262306a36Sopenharmony_ci * 21362306a36Sopenharmony_ci * Note1: These values are completely independent from the ACPI_TYPEs 21462306a36Sopenharmony_ci * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER 21562306a36Sopenharmony_ci * 21662306a36Sopenharmony_ci * Note2: If and when 5 bits becomes insufficient, it would probably be best 21762306a36Sopenharmony_ci * to convert to a 6-byte array of argument types, allowing 8 bits per argument. 21862306a36Sopenharmony_ci */ 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci/* Single, simple types */ 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci#define ARGI_ANYTYPE 0x01 /* Don't care */ 22362306a36Sopenharmony_ci#define ARGI_PACKAGE 0x02 22462306a36Sopenharmony_ci#define ARGI_EVENT 0x03 22562306a36Sopenharmony_ci#define ARGI_MUTEX 0x04 22662306a36Sopenharmony_ci#define ARGI_DDBHANDLE 0x05 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci/* Interchangeable types (via implicit conversion) */ 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#define ARGI_INTEGER 0x06 23162306a36Sopenharmony_ci#define ARGI_STRING 0x07 23262306a36Sopenharmony_ci#define ARGI_BUFFER 0x08 23362306a36Sopenharmony_ci#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ 23462306a36Sopenharmony_ci#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci/* Reference objects */ 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci#define ARGI_INTEGER_REF 0x0B 23962306a36Sopenharmony_ci#define ARGI_OBJECT_REF 0x0C 24062306a36Sopenharmony_ci#define ARGI_DEVICE_REF 0x0D 24162306a36Sopenharmony_ci#define ARGI_REFERENCE 0x0E 24262306a36Sopenharmony_ci#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ 24362306a36Sopenharmony_ci#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ 24462306a36Sopenharmony_ci#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ 24562306a36Sopenharmony_ci#define ARGI_STORE_TARGET 0x12 /* Target for store is TARGETREF + package objects */ 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci/* Multiple/complex types */ 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci#define ARGI_DATAOBJECT 0x13 /* Buffer, String, package or reference to a node - Used only by size_of operator */ 25062306a36Sopenharmony_ci#define ARGI_COMPLEXOBJ 0x14 /* Buffer, String, or package (Used by INDEX op only) */ 25162306a36Sopenharmony_ci#define ARGI_REF_OR_STRING 0x15 /* Reference or String (Used by DEREFOF op only) */ 25262306a36Sopenharmony_ci#define ARGI_REGION_OR_BUFFER 0x16 /* Used by LOAD op only */ 25362306a36Sopenharmony_ci#define ARGI_DATAREFOBJ 0x17 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci/* Note: types above can expand to 0x1F maximum */ 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci#define ARGI_INVALID_OPCODE 0xFFFFFFFF 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci/* 26062306a36Sopenharmony_ci * Some of the flags and types below are of the form: 26162306a36Sopenharmony_ci * 26262306a36Sopenharmony_ci * AML_FLAGS_EXEC_#A_#T,#R, or 26362306a36Sopenharmony_ci * AML_TYPE_EXEC_#A_#T,#R where: 26462306a36Sopenharmony_ci * 26562306a36Sopenharmony_ci * #A is the number of required arguments 26662306a36Sopenharmony_ci * #T is the number of target operands 26762306a36Sopenharmony_ci * #R indicates whether there is a return value 26862306a36Sopenharmony_ci * 26962306a36Sopenharmony_ci * These types are used for the top-level dispatch of the AML 27062306a36Sopenharmony_ci * opcode. They group similar operators that can share common 27162306a36Sopenharmony_ci * front-end code before dispatch to the final code that implements 27262306a36Sopenharmony_ci * the operator. 27362306a36Sopenharmony_ci */ 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci/* 27662306a36Sopenharmony_ci * Opcode information flags 27762306a36Sopenharmony_ci */ 27862306a36Sopenharmony_ci#define AML_LOGICAL 0x0001 27962306a36Sopenharmony_ci#define AML_LOGICAL_NUMERIC 0x0002 28062306a36Sopenharmony_ci#define AML_MATH 0x0004 28162306a36Sopenharmony_ci#define AML_CREATE 0x0008 28262306a36Sopenharmony_ci#define AML_FIELD 0x0010 28362306a36Sopenharmony_ci#define AML_DEFER 0x0020 28462306a36Sopenharmony_ci#define AML_NAMED 0x0040 28562306a36Sopenharmony_ci#define AML_NSNODE 0x0080 28662306a36Sopenharmony_ci#define AML_NSOPCODE 0x0100 28762306a36Sopenharmony_ci#define AML_NSOBJECT 0x0200 28862306a36Sopenharmony_ci#define AML_HAS_RETVAL 0x0400 28962306a36Sopenharmony_ci#define AML_HAS_TARGET 0x0800 29062306a36Sopenharmony_ci#define AML_HAS_ARGS 0x1000 29162306a36Sopenharmony_ci#define AML_CONSTANT 0x2000 29262306a36Sopenharmony_ci#define AML_NO_OPERAND_RESOLVE 0x4000 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ci/* Convenient flag groupings of the flags above */ 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL 29762306a36Sopenharmony_ci#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ 29862306a36Sopenharmony_ci#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ 29962306a36Sopenharmony_ci#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET 30062306a36Sopenharmony_ci#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */ 30162306a36Sopenharmony_ci#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ 30262306a36Sopenharmony_ci#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ 30362306a36Sopenharmony_ci#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */ 30462306a36Sopenharmony_ci#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL 30562306a36Sopenharmony_ci#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS 30662306a36Sopenharmony_ci#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL 30762306a36Sopenharmony_ci#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci/* 31062306a36Sopenharmony_ci * The opcode Type is used in a dispatch table, do not change 31162306a36Sopenharmony_ci * or add anything new without updating the table. 31262306a36Sopenharmony_ci */ 31362306a36Sopenharmony_ci#define AML_TYPE_EXEC_0A_0T_1R 0x00 /* 0 Args, 0 Target, 1 ret_val */ 31462306a36Sopenharmony_ci#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* 1 Args, 0 Target, 0 ret_val */ 31562306a36Sopenharmony_ci#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* 1 Args, 0 Target, 1 ret_val */ 31662306a36Sopenharmony_ci#define AML_TYPE_EXEC_1A_1T_0R 0x03 /* 1 Args, 1 Target, 0 ret_val */ 31762306a36Sopenharmony_ci#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* 1 Args, 1 Target, 1 ret_val */ 31862306a36Sopenharmony_ci#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* 2 Args, 0 Target, 0 ret_val */ 31962306a36Sopenharmony_ci#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* 2 Args, 0 Target, 1 ret_val */ 32062306a36Sopenharmony_ci#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* 2 Args, 1 Target, 1 ret_val */ 32162306a36Sopenharmony_ci#define AML_TYPE_EXEC_2A_2T_1R 0x08 /* 2 Args, 2 Target, 1 ret_val */ 32262306a36Sopenharmony_ci#define AML_TYPE_EXEC_3A_0T_0R 0x09 /* 3 Args, 0 Target, 0 ret_val */ 32362306a36Sopenharmony_ci#define AML_TYPE_EXEC_3A_1T_1R 0x0A /* 3 Args, 1 Target, 1 ret_val */ 32462306a36Sopenharmony_ci#define AML_TYPE_EXEC_6A_0T_1R 0x0B /* 6 Args, 0 Target, 1 ret_val */ 32562306a36Sopenharmony_ci/* End of types used in dispatch table */ 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci#define AML_TYPE_LITERAL 0x0C 32862306a36Sopenharmony_ci#define AML_TYPE_CONSTANT 0x0D 32962306a36Sopenharmony_ci#define AML_TYPE_METHOD_ARGUMENT 0x0E 33062306a36Sopenharmony_ci#define AML_TYPE_LOCAL_VARIABLE 0x0F 33162306a36Sopenharmony_ci#define AML_TYPE_DATA_TERM 0x10 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci/* Generic for an op that returns a value */ 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci#define AML_TYPE_METHOD_CALL 0x11 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_ci/* Miscellaneous types */ 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci#define AML_TYPE_CREATE_FIELD 0x12 34062306a36Sopenharmony_ci#define AML_TYPE_CREATE_OBJECT 0x13 34162306a36Sopenharmony_ci#define AML_TYPE_CONTROL 0x14 34262306a36Sopenharmony_ci#define AML_TYPE_NAMED_NO_OBJ 0x15 34362306a36Sopenharmony_ci#define AML_TYPE_NAMED_FIELD 0x16 34462306a36Sopenharmony_ci#define AML_TYPE_NAMED_SIMPLE 0x17 34562306a36Sopenharmony_ci#define AML_TYPE_NAMED_COMPLEX 0x18 34662306a36Sopenharmony_ci#define AML_TYPE_RETURN 0x19 34762306a36Sopenharmony_ci#define AML_TYPE_UNDEFINED 0x1A 34862306a36Sopenharmony_ci#define AML_TYPE_BOGUS 0x1B 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ci/* AML Package Length encodings */ 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ci#define ACPI_AML_PACKAGE_TYPE1 0x40 35362306a36Sopenharmony_ci#define ACPI_AML_PACKAGE_TYPE2 0x4000 35462306a36Sopenharmony_ci#define ACPI_AML_PACKAGE_TYPE3 0x400000 35562306a36Sopenharmony_ci#define ACPI_AML_PACKAGE_TYPE4 0x40000000 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci/* 35862306a36Sopenharmony_ci * Opcode classes 35962306a36Sopenharmony_ci */ 36062306a36Sopenharmony_ci#define AML_CLASS_EXECUTE 0x00 36162306a36Sopenharmony_ci#define AML_CLASS_CREATE 0x01 36262306a36Sopenharmony_ci#define AML_CLASS_ARGUMENT 0x02 36362306a36Sopenharmony_ci#define AML_CLASS_NAMED_OBJECT 0x03 36462306a36Sopenharmony_ci#define AML_CLASS_CONTROL 0x04 36562306a36Sopenharmony_ci#define AML_CLASS_ASCII 0x05 36662306a36Sopenharmony_ci#define AML_CLASS_PREFIX 0x06 36762306a36Sopenharmony_ci#define AML_CLASS_INTERNAL 0x07 36862306a36Sopenharmony_ci#define AML_CLASS_RETURN_VALUE 0x08 36962306a36Sopenharmony_ci#define AML_CLASS_METHOD_CALL 0x09 37062306a36Sopenharmony_ci#define AML_CLASS_UNKNOWN 0x0A 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_ci/* Comparison operation codes for match_op operator */ 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_citypedef enum { 37562306a36Sopenharmony_ci MATCH_MTR = 0, 37662306a36Sopenharmony_ci MATCH_MEQ = 1, 37762306a36Sopenharmony_ci MATCH_MLE = 2, 37862306a36Sopenharmony_ci MATCH_MLT = 3, 37962306a36Sopenharmony_ci MATCH_MGE = 4, 38062306a36Sopenharmony_ci MATCH_MGT = 5 38162306a36Sopenharmony_ci} AML_MATCH_OPERATOR; 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci#define MAX_MATCH_OPERATOR 5 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ci/* 38662306a36Sopenharmony_ci * field_flags 38762306a36Sopenharmony_ci * 38862306a36Sopenharmony_ci * This byte is extracted from the AML and includes three separate 38962306a36Sopenharmony_ci * pieces of information about the field: 39062306a36Sopenharmony_ci * 1) The field access type 39162306a36Sopenharmony_ci * 2) The field update rule 39262306a36Sopenharmony_ci * 3) The lock rule for the field 39362306a36Sopenharmony_ci * 39462306a36Sopenharmony_ci * Bits 00 - 03 : access_type (any_acc, byte_acc, etc.) 39562306a36Sopenharmony_ci * 04 : lock_rule (1 == Lock) 39662306a36Sopenharmony_ci * 05 - 06 : update_rule 39762306a36Sopenharmony_ci */ 39862306a36Sopenharmony_ci#define AML_FIELD_ACCESS_TYPE_MASK 0x0F 39962306a36Sopenharmony_ci#define AML_FIELD_LOCK_RULE_MASK 0x10 40062306a36Sopenharmony_ci#define AML_FIELD_UPDATE_RULE_MASK 0x60 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ci/* 1) Field Access Types */ 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_citypedef enum { 40562306a36Sopenharmony_ci AML_FIELD_ACCESS_ANY = 0x00, 40662306a36Sopenharmony_ci AML_FIELD_ACCESS_BYTE = 0x01, 40762306a36Sopenharmony_ci AML_FIELD_ACCESS_WORD = 0x02, 40862306a36Sopenharmony_ci AML_FIELD_ACCESS_DWORD = 0x03, 40962306a36Sopenharmony_ci AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ 41062306a36Sopenharmony_ci AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ 41162306a36Sopenharmony_ci} AML_ACCESS_TYPE; 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci/* 2) Field Lock Rules */ 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_citypedef enum { 41662306a36Sopenharmony_ci AML_FIELD_LOCK_NEVER = 0x00, 41762306a36Sopenharmony_ci AML_FIELD_LOCK_ALWAYS = 0x10 41862306a36Sopenharmony_ci} AML_LOCK_RULE; 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci/* 3) Field Update Rules */ 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_citypedef enum { 42362306a36Sopenharmony_ci AML_FIELD_UPDATE_PRESERVE = 0x00, 42462306a36Sopenharmony_ci AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, 42562306a36Sopenharmony_ci AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 42662306a36Sopenharmony_ci} AML_UPDATE_RULE; 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci/* 42962306a36Sopenharmony_ci * Field Access Attributes. 43062306a36Sopenharmony_ci * This byte is extracted from the AML via the 43162306a36Sopenharmony_ci * access_as keyword 43262306a36Sopenharmony_ci */ 43362306a36Sopenharmony_citypedef enum { 43462306a36Sopenharmony_ci AML_FIELD_ATTRIB_QUICK = 0x02, 43562306a36Sopenharmony_ci AML_FIELD_ATTRIB_SEND_RECEIVE = 0x04, 43662306a36Sopenharmony_ci AML_FIELD_ATTRIB_BYTE = 0x06, 43762306a36Sopenharmony_ci AML_FIELD_ATTRIB_WORD = 0x08, 43862306a36Sopenharmony_ci AML_FIELD_ATTRIB_BLOCK = 0x0A, 43962306a36Sopenharmony_ci AML_FIELD_ATTRIB_BYTES = 0x0B, 44062306a36Sopenharmony_ci AML_FIELD_ATTRIB_PROCESS_CALL = 0x0C, 44162306a36Sopenharmony_ci AML_FIELD_ATTRIB_BLOCK_PROCESS_CALL = 0x0D, 44262306a36Sopenharmony_ci AML_FIELD_ATTRIB_RAW_BYTES = 0x0E, 44362306a36Sopenharmony_ci AML_FIELD_ATTRIB_RAW_PROCESS_BYTES = 0x0F 44462306a36Sopenharmony_ci} AML_ACCESS_ATTRIBUTE; 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ci/* Bit fields in the AML method_flags byte */ 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_ci#define AML_METHOD_ARG_COUNT 0x07 44962306a36Sopenharmony_ci#define AML_METHOD_SERIALIZED 0x08 45062306a36Sopenharmony_ci#define AML_METHOD_SYNC_LEVEL 0xF0 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci#endif /* __AMLCODE_H__ */ 453