Skip to content

acpi: add DSDT device type#1165

Merged
lgfa29 merged 4 commits into
masterfrom
acpi-dsdt-device-type
Jul 10, 2026
Merged

acpi: add DSDT device type#1165
lgfa29 merged 4 commits into
masterfrom
acpi-dsdt-device-type

Conversation

@lgfa29

@lgfa29 lgfa29 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Allow DsdtGenerator to specify the type of device it is generating code for. The DSDT can then organize devices types in a stable order, regardless of the component name and position in the device map.

Allow `DsdtGenerator` to specify the type of device it is generating
code for. The DSDT can then organize devices types in a stable order,
regardless of the component name and position in the device map.
&PciRootBridge { config: &self.config },
&DsdtGeneratorAml {
scope: DsdtScope::SystemBus,
device_type: None,

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 main thought i've got here is: while i think this gives Propolis good control over how to lay out items in the tables (and so, broadly, i'm a fan!) if we have a device on SystemBus and forget to add a stanza to emit the AML here, it'll probably be really confusing and frustrating to debug.

i'm imagining that maybe we could have a bit on devices to report if we've printed their AML, though to_aml_bytes takes &self, so we'd either change that or otherwise do interior mutability. then finally we could have an impl Drop for DsdtConfig that checks our work (and warns or panics or something if there are devices we've forgotten about).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, that's a good point. Is 8d38895 more or less what you had in mind?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looking at this with fresh eyes today, I think it makes more sense to keep state in Dsdt rather DsdtConfig. That way DsdtConfig is just a container for configuration values. I moved the generator state in 42acb24

@iximeow iximeow 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.

nice, lets do it! nit is only because I'd want to make sure we don't forget about that last outstanding detail but I really don't think it's worth effort at the moment. thank you for the attention here 🙏

Comment on lines +109 to +112
.filter(|&(_, &g)| {
g.dsdt_scope() == self.scope
&& g.device_type() == self.device_type
})

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.

so.. I'm realizing one wrinkle we'll still have is that we're at the whim of SpecKey ordering for a given device_type. that is, if something sends propolis-server an InstanceSpec which has four serial ports named com{1,2,3,4}, then changes how it adds serial ports such that they're named com{4,3,2,1} but name ports in ascending order, we'll dutifully reverse the order of those ports' AML.

we can probably demand that items implement Ord so we can sort the filtered generators? but this is all pretty niche compared to the current issue you're fixing. and it's not like we have anything else that's present multiple times in the ACPI tables. so as emphatically as I can say: I think we should land this with an issue and note about the remaining SpecKey sensitivity

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hum...right. Although the generators are sorted by SpecKey, so you would need to have a weird combination where the serial port key didn't quite match the port number. Weird, but still possible 😄

I added a note about it in a2f33de and I will open a follow-up issue.

}

#[test]
#[should_panic(expected = "DSDT generators not called")]

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.

perf, thank you 🙌

@lgfa29
lgfa29 merged commit aabd9a0 into master Jul 10, 2026
14 checks passed
@lgfa29
lgfa29 deleted the acpi-dsdt-device-type branch July 10, 2026 15:53
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