mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-04-20 03:36:25 +09:00
Compare commits
2 commits
9971774a01
...
76595d0c92
Author | SHA1 | Date | |
---|---|---|---|
76595d0c92 | |||
06a5429583 |
2 changed files with 13 additions and 24 deletions
|
@ -48,30 +48,10 @@ 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)?;
|
let register_map = types::Module::from_xml_dom(doc.root_element(), xml_git_info)?;
|
||||||
log::debug!("converted {register_map:?}");
|
log::debug!("converted {register_map:?}");
|
||||||
|
|
||||||
let (maps, errors) = register_map.validate();
|
let (_maps, errors) = register_map.validate();
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
return Err(Error::RegmapValidationError(errors));
|
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()?;
|
let files = register_map.generate_code()?;
|
||||||
if log::log_enabled!(log::Level::Debug) {
|
if log::log_enabled!(log::Level::Debug) {
|
||||||
|
|
|
@ -24,6 +24,8 @@ pub enum ValidationError {
|
||||||
existing_name: String,
|
existing_name: String,
|
||||||
new_name: String,
|
new_name: String,
|
||||||
},
|
},
|
||||||
|
#[error("address 0x{address:08x} is out of range: \"{name}\"")]
|
||||||
|
AddressOutofRange { address: u32, name: String },
|
||||||
#[error("unsupported structure: {msg}")]
|
#[error("unsupported structure: {msg}")]
|
||||||
UnsupportedStructure { msg: &'static str },
|
UnsupportedStructure { msg: &'static str },
|
||||||
}
|
}
|
||||||
|
@ -105,9 +107,16 @@ impl Validate for Register {
|
||||||
};
|
};
|
||||||
for id in 0..len {
|
for id in 0..len {
|
||||||
let addr = addr + id * offset;
|
let addr = addr + id * offset;
|
||||||
let regmap: &mut Option<_> = mapping
|
let regmap: &mut Option<_> = match mapping.get_mut::<usize>(addr.try_into().unwrap()) {
|
||||||
.get_mut::<usize>(addr.try_into().unwrap())
|
Some(regmap) => regmap,
|
||||||
.expect("index of mapping out of range");
|
None => {
|
||||||
|
errors.push(ValidationError::AddressOutofRange {
|
||||||
|
address: addr,
|
||||||
|
name: self.name.clone(),
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
if let Some(old) = regmap {
|
if let Some(old) = regmap {
|
||||||
let existing_name = {
|
let existing_name = {
|
||||||
let mut path = old.0.clone();
|
let mut path = old.0.clone();
|
||||||
|
|
Loading…
Add table
Reference in a new issue