Skip to content

Handle DerefOf buffer fields#317

Merged
IsaacWoods merged 1 commit into
rust-osdev:mainfrom
ArthurHeymans:DerefOf
Jul 25, 2026
Merged

Handle DerefOf buffer fields#317
IsaacWoods merged 1 commit into
rust-osdev:mainfrom
ArthurHeymans:DerefOf

Conversation

@ArthurHeymans

Copy link
Copy Markdown
Contributor

Allow DerefOf to read directly from BufferField objects. This matches AML patterns emitted by firmware that creates named fields over buffers and then uses DerefOf(field).

Comment thread src/aml/mod.rs
context.start(OpInFlight::new(opcode, &[ResolveBehaviour::TermArg, ResolveBehaviour::Target]))
}
Opcode::DerefOf => context.start(OpInFlight::new(opcode, &[ResolveBehaviour::TermArg])),
Opcode::DerefOf => context.start(OpInFlight::new(opcode, &[ResolveBehaviour::SuperName])),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you sure this should change to SuperName? The spec has TermArg (https://uefi.org/specs/ACPI/6.6/20_AML_Specification.html#defderefof and click ObjectReference)

... I guess it's to avoid repetition of the field/buffer read code from the ResolveBehaviour::TermArg => { arm of the match behaviour block?

If so I understand the motivation and am not against it but I think it'd be worth a comment to explain

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's indeed intentional as resolving this as TermArg would eagerly read BufferField and FieldUnit objects before DerefOf executes. I added 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.

Yep, that makes sense! Thanks!

@martin-hughes

Copy link
Copy Markdown
Contributor

Apart from my question above this looks good to me!

Especially appreciate you:

  • adding some test cases
  • running the formatter I evidently forgot to in one of my earlier PRs 😆

Isaac, to save you a little time I can tell you I merged this into my fork and the code and tests all seem to work just fine

Allow DerefOf to read directly from BufferField objects. This matches AML
patterns emitted by firmware that creates named fields over buffers and then
uses DerefOf(field).
@IsaacWoods

Copy link
Copy Markdown
Member

Great, thanks for the PR! And thank you to @martin-hughes for his review and testing

@IsaacWoods
IsaacWoods merged commit 7c7a89d into rust-osdev:main Jul 25, 2026
@ArthurHeymans
ArthurHeymans deleted the DerefOf branch July 25, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants