svd_parser/
cpu.rs

1use super::*;
2use crate::svd::{Cpu, Endian};
3use crate::types::BoolParse;
4
5impl Parse for Cpu {
6    type Object = Self;
7    type Error = SVDErrorAt;
8    type Config = Config;
9
10    fn parse(tree: &Node, config: &Config) -> Result<Self, Self::Error> {
11        if !tree.has_tag_name("cpu") {
12            return Err(SVDError::NotExpectedTag("cpu".to_string()).at(tree.id()));
13        }
14
15        Cpu::builder()
16            .name(tree.get_child_text("name")?)
17            .revision(tree.get_child_text("revision")?)
18            .endian(Endian::parse(&tree.get_child_elem("endian")?, config)?)
19            .mpu_present(tree.get_child_bool("mpuPresent")?)
20            .fpu_present(tree.get_child_bool("fpuPresent")?)
21            .fpu_double_precision(optional::<BoolParse>("fpuDP", tree, &())?)
22            .dsp_present(optional::<BoolParse>("dspPresent", tree, &())?)
23            .icache_present(optional::<BoolParse>("icachePresent", tree, &())?)
24            .dcache_present(optional::<BoolParse>("dcachePresent", tree, &())?)
25            .itcm_present(optional::<BoolParse>("itcmPresent", tree, &())?)
26            .dtcm_present(optional::<BoolParse>("dtcmPresent", tree, &())?)
27            .vtor_present(optional::<BoolParse>("vtorPresent", tree, &())?)
28            .nvic_priority_bits(tree.get_child_u32("nvicPrioBits")?)
29            .has_vendor_systick(tree.get_child_bool("vendorSystickConfig")?)
30            .device_num_interrupts(optional::<u32>("deviceNumInterrupts", tree, &())?)
31            .sau_num_regions(optional::<u32>("sauNumRegions", tree, &())?)
32            .build(config.validate_level)
33            .map_err(|e| SVDError::from(e).at(tree.id()))
34    }
35}