Interrupts
Rahix opened this issue · 1 comments
Right now, the interrupt list specified in the atdf
file is completely ignored. atdf2svd
definitely needs a way to add them to the svd file, but unfortunately, this is not quite trivial: The atdf does not associate interrupts with peripherals like svd does ... I am currently in favor of just adding all interrupts to the CPU peripheral unconditionally, as svd2rust
does not care about this association anyway ...
Implementation
Data-Structure Changes
Add a new list of interrupts to the Chip
struct. Probably similar to
pub struct Chip {
pub name: String,
// ...
pub peripherals: HashMap<String, Peripheral>,
pub interrupts: HashMap<String, Interrupt>,
}
This interrupt type also needs to be defined:
pub struct Interrupt {
pub name: String,
pub description: Option<String>,
pub index: usize,
}
Parsing
The interrupt list should be filled with the interrupts from the <interrupts>
element. Probably in atdf/chip.rs
. Look at the other parsers and try to mimic what they do to get this working.
svd-Generation
The idea is to add all interrupts to the CPU
peripheral in the svd file. To do so, after generating all peripherals, attach a new child-tree to the CPU
peripheral. This should happen in svd/chip.rs
(Line 28+). Reference the svd documentation for details about that.
Unfortunately, there is no easy way to access the CPU
peripheral, so what you'll probably end up with is looping over all peripherals until you find it:
for peripheral in peripherals.children.iter_mut() {
if let Some("CPU") = peripheral.get_child("name") {
// Add interrupts
peripheral.children.push(...);
break;
}
}