Compare commits

..

No commits in common. "76595d0c92ebb4ee9e2a25aeeaa53b787cb51468" and "9971774a0142bdb807b79b1d18684d890b3ecce5" have entirely different histories.

2 changed files with 24 additions and 13 deletions

View file

@ -48,10 +48,30 @@ pub fn generate(xml: &path::Path, out: &path::Path) -> Result<(), Error> {
let register_map = types::Module::from_xml_dom(doc.root_element(), xml_git_info)?;
log::debug!("converted {register_map:?}");
let (_maps, errors) = register_map.validate();
let (maps, errors) = register_map.validate();
if !errors.is_empty() {
return Err(Error::RegmapValidationError(errors));
}
// TODO: this is a temporarily implementation
println!("address,path,name,multiple_id,modf,description");
for (addr, reg) in maps.iter().enumerate() {
match reg {
Some(reg) => {
let path = reg.0.join("/");
let multiple_id = reg.2.map_or("".to_string(), |x| x.to_string());
println!(
"0x{:04x},{},{},{},{},{},",
addr,
path,
reg.1.name,
multiple_id,
reg.1.modf,
reg.1.desc.as_ref().map_or_else(|| "", |s| s),
)
}
None => println!("0x{:04x},,,,", addr),
}
}
let files = register_map.generate_code()?;
if log::log_enabled!(log::Level::Debug) {

View file

@ -24,8 +24,6 @@ pub enum ValidationError {
existing_name: String,
new_name: String,
},
#[error("address 0x{address:08x} is out of range: \"{name}\"")]
AddressOutofRange { address: u32, name: String },
#[error("unsupported structure: {msg}")]
UnsupportedStructure { msg: &'static str },
}
@ -107,16 +105,9 @@ impl Validate for Register {
};
for id in 0..len {
let addr = addr + id * offset;
let regmap: &mut Option<_> = match mapping.get_mut::<usize>(addr.try_into().unwrap()) {
Some(regmap) => regmap,
None => {
errors.push(ValidationError::AddressOutofRange {
address: addr,
name: self.name.clone(),
});
continue;
}
};
let regmap: &mut Option<_> = mapping
.get_mut::<usize>(addr.try_into().unwrap())
.expect("index of mapping out of range");
if let Some(old) = regmap {
let existing_name = {
let mut path = old.0.clone();