mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-04-21 04:06:03 +09:00
Compare commits
No commits in common. "76595d0c92ebb4ee9e2a25aeeaa53b787cb51468" and "9971774a0142bdb807b79b1d18684d890b3ecce5" have entirely different histories.
76595d0c92
...
9971774a01
2 changed files with 24 additions and 13 deletions
|
@ -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)?;
|
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,8 +24,6 @@ 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 },
|
||||||
}
|
}
|
||||||
|
@ -107,16 +105,9 @@ 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<_> = match mapping.get_mut::<usize>(addr.try_into().unwrap()) {
|
let regmap: &mut Option<_> = mapping
|
||||||
Some(regmap) => regmap,
|
.get_mut::<usize>(addr.try_into().unwrap())
|
||||||
None => {
|
.expect("index of mapping out of range");
|
||||||
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