Skip to content

LibACPI: Add enough stuff to load the Qemu DSDT (3/N) - #27134

Open
cqundefine wants to merge 18 commits into
SerenityOS:masterfrom
cqundefine:acpi3
Open

cqundefine wants to merge 18 commits into
SerenityOS:masterfrom
cqundefine:acpi3

Conversation

@cqundefine

Copy link
Copy Markdown
Contributor

This adds enough features to allow our AML interpreter to load the standard DSDT provided but Qemu.

cqundefine and others added 18 commits October 29, 2026 08:14
Some opcodes encode how many bytes a list of something takes, this
will be needed very soon.
Sometimes reading an operand doesn't produce an operand, but a node or
something else.
When an opcode would get filtered at root it would try to get the
opcode value to print the error message, which is absent on the root
frame.
The comment noted these should be added, but I accidentally left them
out when refactoring.

Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
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 <ratchetnumbers@proton.me>
It was mistakenly added in the previous PR even though it never has any
other argument than nullptr.
For now just create a node, but don't actually do anything with the
body as it's not needed for now.

Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Do this similarly to repeating over a byte count.
Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
While this opcode is deprecated, it is still widely used and we need to
support it.

Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Now that we have all the primitives we need, let's add the missing
objects.

Co-authored-by: RatcheT2497 <ratchetnumbers@proton.me>
Just as the previous test, the AML table was compiled with using
IASL 20260930 without any flags.
@cqundefine cqundefine changed the title LibACPI: Add enough stuff to load the Qemu DSDT LibACPI: Add enough stuff to load the Qemu DSDT (3/N) Oct 29, 2026
@github-actions github-actions Bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Oct 29, 2026

@spholz spholz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +106 to +107
PCC = 10,
PRM = 11,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the spec also has these as full words. We usually prefer full words over abbreviations unless where the abbreviation is easier to understand and more common.

(I personally don't know what these stand for.)

Comment on lines +106 to +107
PCC = 10,
PRM = 11,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nit: Why didn't you keep these as hex? The spec has them as hex.

// opcodes here, I'm adding it in here.
// DeviceOp is also missing. Adding it here too.
// MutexOp likewise missing. It's named and creates an object, so here it be.
// DeviceOp, MethodOp and MutexOp are also missing. Adding it here too beacuse they also create an object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/it/them, s/beacuse/because

OperandType::ByteData,
OperandType::TermArg,
OperandType::TermArg,
OperandType::End

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please add trailing commas for every multi-line initializer like this.


protected:
u8 m_space_raw;
i64 m_offset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using i64 here now, but u64 everywhere else for ACPI integers. Are ACPI integers signed or unsigned? Or does that depend on the usage of them?

auto value = MUST(m_data.as<String>());
TRY(builder.try_appendff("('{}')"sv, StringView(value.buffer())));
} else if (m_data.is<Buffer>()) {
TRY(builder.try_append("Buffer"sv));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we print the buffer contents (with :hex-dump maybe)?

} else if (m_data.is<Buffer>()) {
TRY(builder.try_append("Buffer"sv));
} else if (m_data.is<Package>()) {
TRY(builder.try_append("Package"sv));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to print the contents here. Easiest way to do so would be to add a formatter for Object. Then the Vector formatter should just work.

DEBUG_LOG("Reading package element...");

auto initial = TRY(stream.peek_byte());
if (is_namestring_start(initial)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we print an interpreter error for types that we don't support yet here? Or do I not understand how this works?

I'm also confused by the "// NOTE: Reading NameString will be handled a different way." comment. In what different way?

StringView kind() const override { return "Processor"sv; }

protected:
u32 m_address { 0 };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ACPI 6.3 spec seems to call this the address of the "processor register block". And m_block_length the length of it.

Comment thread Tests/LibACPI/TestAML.cpp
{
auto interpreter = TRY_OR_FAIL(load_test_table("data_objects_and_named_objects.aml"sv));

auto string = TRY_OR_FAIL(interpreter->evaluate(TRY_OR_FAIL(ACPI::AML::NameString::from_string_view("\\STR0"sv))));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing these ACPI::AML::NameString::from_string_view everywhere makes me feel like we should add a StringView overload to evaluate maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants