Skip to content

Commit

Permalink
Merge pull request #791 from fortify-iq/new-config-flag
Browse files Browse the repository at this point in the history
Add `base-address-shift` configuration flag
  • Loading branch information
burrbull authored Jan 10, 2024
2 parents e21c210 + fa91c39 commit 869d34f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Add `base-address-shift` config flag

## [v0.31.5] - 2024-01-04

- `move` in `RegisterBlock::reg_iter` implementation (iterator of register/cluster array)
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct Config {
pub reexport_core_peripherals: bool,
pub reexport_interrupt: bool,
pub ident_formats: IdentFormats,
pub base_address_shift: u64,
}

#[allow(clippy::upper_case_acronyms)]
Expand Down
4 changes: 2 additions & 2 deletions src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let span = Span::call_site();
let p_ty = ident(&name, &config.ident_formats.peripheral, span);
let name_str = p_ty.to_string();
let address = util::hex(p.base_address);
let address = util::hex(p.base_address + config.base_address_shift);
let description = util::respace(p.description.as_ref().unwrap_or(&p.name));

let mod_ty = name.to_snake_case_ident(span);
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let description = pi.description.as_deref().unwrap_or(&p.name);
let p_ty = ident(name, &config.ident_formats.peripheral, span);
let name_str = p_ty.to_string();
let address = util::hex(pi.base_address);
let address = util::hex(pi.base_address + config.base_address_shift);
let p_snake = name.to_sanitized_snake_case();
snake_names.push(p_snake.to_string());
let mut feature_attribute_n = feature_attribute.clone();
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ fn run() -> Result<()> {
.action(ArgAction::SetTrue)
.help("Reexport interrupt macro from cortex-m-rt like crates"),
)
.arg(
Arg::new("base_address_shift")
.short('b')
.long("base-address-shift")
.alias("base_address_shift")
.action(ArgAction::Set)
.help("Add offset to all base addresses on all peripherals in the SVD file.")
.long_help("Add offset to all base addresses on all peripherals in the SVD file.
Useful for soft-cores where the peripheral address range isn't necessarily fixed.
Ignore this option if you are not building your own FPGA based soft-cores."),
)
.arg(
Arg::new("log_level")
.long("log")
Expand Down

0 comments on commit 869d34f

Please sign in to comment.