Skip to content

aml: deliver Notify to the host through Handler::handle_notify - #380

Open
lexoliu wants to merge 1 commit into
rust-osdev:mainfrom
lexoliu:aml-notify-handler
Open

lexoliu wants to merge 1 commit into
rust-osdev:mainfrom
lexoliu:aml-notify-handler

Conversation

@lexoliu

@lexoliu lexoliu commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Notify is how firmware tells the OS about hotplug and status changes — QEMU's CPU and PCI hotplug AML, battery and thermal events — but the interpreter currently drops it. This adds Handler::handle_notify(&AmlName, u64), mirroring ACPICA's notify handlers; the default implementation still ignores the notification.

The operand is still resolved as a SuperName, so Notify (Arg0, …) and a RefOf held in a local keep working; the interpreter looks up which namespace entry holds the resolved object and hands the handler its absolute path. An object that no entry holds is reported as AmlError::ObjectNotInNamespace.

tests/notify.rs covers relative, absolute and parent-prefixed names, an argument, and a reference in a local.

Notify resolves its operand as a SuperName, so a name, an argument, a
local or a reference all reach the same object; the interpreter finds the
namespace entry holding that object and passes its absolute path and the
notification value to the new Handler::handle_notify. The default ignores
the notification, as ACPICA does with no notify handler installed.
@martin-hughes

Copy link
Copy Markdown
Contributor

Thanks for this @lexoliu!

I'd like to spend some time discussing with Isaac about exactly what our Notify support should look like, so it might take a while before we progress this - apologies.

For example: Is a single Notify handler appropriate? Maybe we want to follow the model of ACPICA and Windows where notification handlers are installed against namespace objects, rather than having a single notify handler for the entire namespace.

OTOH, we might well decide this is a sensible implementation for now and do something fancier later. Please bear with us!

@martin-hughes martin-hughes left a comment

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.

Hi @lexoliu - thanks for your patience!

Isaac and I think using a single notify method on the Handler1 is a reasonable way to go so I've reviewed your PR. We appreciate your work on this!

There's nothing too major in my comments, although I'd like to hear your thoughts about merging NotifyRecorder and CheckCommandHandler.

Footnotes

  1. as opposed to having handlers installed against specific objects ↩

Comment thread src/aml/namespace.rs

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.

Nitpick: cargo fmt slightly changes your code in path_of - please could you run cargo fmt?

Comment thread tests/notify.rs
}

/// A [`NullHandler`] that records every notification it receives.
#[derive(Clone, Default)]

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.

Please could the tests be grouped together? (As opposed to having this handler in the middle)

Did you consider merging this with CheckCommandHandler?

Comment thread src/aml/object.rs

impl WrappedObject {
/// Returns `true` if both wrappers refer to the same underlying object.
pub(crate) fn ptr_eq(&self, other: &WrappedObject) -> bool {

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.

Please move this function into the main impl block instead of starting a new one.

Comment thread tests/notify.rs
let path = AmlName::from_str("\\_SB_.CPUS.C001").unwrap();
let expected: Vec<_> = [0x01, 0x02, 0x80, 0x03, 0x04].into_iter().map(|value| (path.clone(), value)).collect();
assert_eq!(*notifications.lock().unwrap(), expected);
}

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.

Please would you add a test of the error path? e.g.

Local0 = 1 // Local0 does not refer to a namespace object
Notify(Local0, 2)

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.

2 participants