repnop / fdt

Rust crate for Flattened Devicetree parsing
Mozilla Public License 2.0
39 stars 19 forks source link

Create trait for defining custom nodes that can be easily extracted from the `Fdt` #14

Open jongwu opened 8 months ago

jongwu commented 8 months ago

Hello I'm new here and do some development based on this project.

I want to carry some self-defined info inside chosen, like store kernel info inside chosen node. But I get that, chosen node is private and can't be used outside. So, I wonder if it is likely to expose chosen as public or can I add self-defined chosen releated interface to this repo?

jongwu commented 8 months ago

@repnop -, Any comments?

repnop commented 8 months ago

Hi! I'm not 100% I understand what you mean, but this crate only supports a read-only view into the given flattened devicetree, as such its not possible to store that information anywhere, so even if it was possible to create your own Chosen, you would still need to store it separately. Having an API for creating a new devicetree based on an existing one is something that would make that possible and something I plan to create at some point, but would be probably be pretty heavy handed for simply inserting some information into a single node. My recommendation is to copy the contents that you want out of the Chosen node and use a custom struct to store the rest of the information you need. Hope that helps!

jongwu commented 8 months ago

Hi! I'm not 100% I understand what you mean,

Sorry to have not made it clear.

but this crate only supports a read-only view into the given flattened devicetree, as such its not possible to store that information anywhere, so even if it was possible to create your own Chosen, you would still need to store it separately.

My case is for virtualization scenario. For example, store kernel image into memory and store its location address and size into FDT throught Chosen node in VMM, as the initramfs does. Then we can get those kernel information in guest firmware/kernel.

Having an API for creating a new devicetree based on an existing one is something that would make that possible and something I plan to create at some point,

I prefer this way,

but would be probably be pretty heavy handed for simply inserting some information into a single node. My recommendation is to copy the contents that you want out of the Chosen node and use a custom struct to store the rest of the information you need. Hope that helps!

You mean create a new node in "fdt" (I mean in this repo) to carry what I want?

jongwu commented 7 months ago

Hello @repnop -, I raise a PR to demo what I want to do. We can discuss this issue there.

repnop commented 2 months ago

Co-opting this issue and reusing it for tracking a trait to better define custom nodes so users can more easily access things