//! AML opcode constants — the full ACPI Machine Language opcode table.
//!
//! Single-byte opcodes are plain values. Extended opcodes are a two-byte sequence
//! `ext_prefix` (0x5B) followed by a byte listed under `ext`. A few comparison
//! opcodes are `lnot_opcode` (0x92) followed by a second byte (see `lnot`).

// --- name / path characters -------------------------------------------------
pub const zero_opcode = 0x00;
pub const one_opcode = 0x01;
pub const alias_opcode = 0x06;
pub const name_opcode = 0x08;
pub const byte_prefix = 0x0A;
pub const word_prefix = 0x0B;
pub const dword_prefix = 0x0C;
pub const string_prefix = 0x0D;
pub const qword_prefix = 0x0E;
pub const scope_opcode = 0x10;
pub const buffer_opcode = 0x11;
pub const package_opcode = 0x12;
pub const var_package_opcode = 0x13;
pub const method_opcode = 0x14;
pub const external_opcode = 0x15;

pub const dual_name_prefix = 0x2E;
pub const multi_name_prefix = 0x2F;
pub const extended_opcode_prefix = 0x5B;
pub const root_char = 0x5C;
pub const parent_prefix_char = 0x5E;
pub const name_char_underscore = 0x5F;

pub const digit_char_start = 0x30;
pub const digit_char_end = 0x39;
pub const name_char_start = 0x41; // 'A'
pub const name_char_end = 0x5A; // 'Z'

// --- locals / args ----------------------------------------------------------
pub const local0_opcode = 0x60;
pub const local7_opcode = 0x67;
pub const arg0_opcode = 0x68;
pub const arg6_opcode = 0x6E;

// --- store / references / arithmetic ---------------------------------------
pub const store_opcode = 0x70;
pub const ref_of_opcode = 0x71;
pub const add_opcode = 0x72;
pub const concat_opcode = 0x73;
pub const subtract_opcode = 0x74;
pub const increment_opcode = 0x75;
pub const decrement_opcode = 0x76;
pub const multiply_opcode = 0x77;
pub const divide_opcode = 0x78;
pub const shift_left_opcode = 0x79;
pub const shift_right_opcode = 0x7A;
pub const and_opcode = 0x7B;
pub const nand_opcode = 0x7C;
pub const or_opcode = 0x7D;
pub const nor_opcode = 0x7E;
pub const xor_opcode = 0x7F;
pub const not_opcode = 0x80;
pub const find_set_left_bit_opcode = 0x81;
pub const find_set_right_bit_opcode = 0x82;
pub const dereference_of_opcode = 0x83;
pub const concat_resource_opcode = 0x84;
pub const mod_opcode = 0x85;
pub const notify_opcode = 0x86;
pub const size_of_opcode = 0x87;
pub const index_opcode = 0x88;
pub const match_opcode = 0x89;
pub const create_dword_field_opcode = 0x8A;
pub const create_word_field_opcode = 0x8B;
pub const create_byte_field_opcode = 0x8C;
pub const create_bit_field_opcode = 0x8D;
pub const object_type_opcode = 0x8E;
pub const create_qword_field_opcode = 0x8F;

pub const land_opcode = 0x90;
pub const lor_opcode = 0x91;
pub const lnot_opcode = 0x92; // may be followed by a second byte (see `lnot`)
pub const lequal_opcode = 0x93;
pub const lgreater_opcode = 0x94;
pub const lless_opcode = 0x95;
pub const to_buffer_opcode = 0x96;
pub const to_decimal_string_opcode = 0x97;
pub const to_hex_string_opcode = 0x98;
pub const to_integer_opcode = 0x99;
pub const to_string_opcode = 0x9C;
pub const copy_object_opcode = 0x9D;
pub const mid_opcode = 0x9E;
pub const continue_opcode = 0x9F;
pub const if_opcode = 0xA0;
pub const else_opcode = 0xA1;
pub const while_opcode = 0xA2;
pub const noop_opcode = 0xA3;
pub const return_opcode = 0xA4;
pub const break_opcode = 0xA5;
pub const break_point_opcode = 0xCC;
pub const ones_opcode = 0xFF;

/// Second bytes of the `lnot_opcode` (0x92) compound comparison opcodes.
pub const lnot = struct {
    pub const not_equal = 0x93; // LNotEqualOp: 0x92 0x93
    pub const less_equal = 0x94; // LLessEqualOp: 0x92 0x94
    pub const greater_equal = 0x95; // LGreaterEqualOp: 0x92 0x95
};

/// Second bytes of extended opcodes (prefixed by `extended_opcode_prefix`, 0x5B).
pub const extended = struct {
    pub const mutex = 0x01;
    pub const event = 0x02;
    pub const conditional_reference_of = 0x12;
    pub const create_field = 0x13;
    pub const load_table = 0x1F;
    pub const load = 0x20;
    pub const stall = 0x21;
    pub const sleep = 0x22;
    pub const acquire = 0x23;
    pub const signal = 0x24;
    pub const wait = 0x25;
    pub const reset = 0x26;
    pub const release = 0x27;
    pub const from_bcd = 0x28;
    pub const to_bcd = 0x29;
    pub const unload = 0x2A;
    pub const revision = 0x30;
    pub const debug = 0x31;
    pub const fatal = 0x32;
    pub const timer = 0x33;
    pub const operation_region = 0x80;
    pub const field = 0x81;
    pub const device = 0x82;
    pub const processor = 0x83;
    pub const power_resource = 0x84;
    pub const thermal_zone = 0x85;
    pub const index_field = 0x86;
    pub const bank_field = 0x87;
    pub const data_region = 0x88;
};
