mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
Those two always come in pairs so lets do it in one commit. This doesn't yet support evaluating fields as it's not yet needed and would require setting up callbacks from the interpreter. Co-authored-by: RatcheT2497 <[email protected]>
76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2025, RatcheT2497 <[email protected]>
|
|
* Copyright (c) 2026, Undefine <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <LibACPI/Definitions.h>
|
|
#include <LibACPI/Object.h>
|
|
|
|
namespace ACPI::AML {
|
|
|
|
enum class OperandType : u8 {
|
|
NameString,
|
|
PackageLength,
|
|
ByteData,
|
|
WordData,
|
|
DWordData,
|
|
QWordData,
|
|
|
|
FieldElement,
|
|
TermArg,
|
|
|
|
DataRefObject,
|
|
|
|
MarkAsCount,
|
|
RepeatNextBytes,
|
|
End,
|
|
};
|
|
|
|
class OpcodeFrame {
|
|
public:
|
|
static ErrorOr<OpcodeFrame> from_opcode(Opcode opcode, size_t start);
|
|
static ErrorOr<OpcodeFrame> root_frame();
|
|
|
|
bool filter_opcode_for_next_operand(Opcode opcode);
|
|
|
|
ErrorOr<OperandType> begin_operand(size_t current_offset);
|
|
ErrorOr<void> finish_operand(size_t current_offset);
|
|
ErrorOr<void> finish_operand(Object const& operand, size_t current_offset);
|
|
|
|
Object const& operand(size_t index) const { return m_operands[index]; }
|
|
size_t operand_count() const { return m_operands.size(); }
|
|
|
|
// NOTE: This should never get called on the root frame
|
|
Opcode opcode() const { return m_opcode.value(); }
|
|
size_t start() const { return m_start; }
|
|
|
|
private:
|
|
OpcodeFrame(Optional<Opcode> opcode, Vector<OperandType> operand_template, size_t start)
|
|
: m_opcode(opcode)
|
|
, m_operand_template(move(operand_template))
|
|
, m_start(start)
|
|
{
|
|
}
|
|
|
|
OperandType peek_next_operand();
|
|
bool check_repeat_opcodes(size_t current_offset);
|
|
|
|
Optional<Opcode> m_opcode;
|
|
Vector<Object> m_operands;
|
|
|
|
Vector<OperandType> m_operand_template;
|
|
size_t m_start;
|
|
|
|
size_t m_operand_template_index { 0 };
|
|
|
|
size_t m_counter_value_index { 0 };
|
|
Optional<size_t> m_counter;
|
|
};
|
|
|
|
}
|