Skip to content

Commit 869d34f

Browse files
authoredJan 10, 2024
Merge pull request #791 from fortify-iq/new-config-flag
Add `base-address-shift` configuration flag
2 parents e21c210 + fa91c39 commit 869d34f

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
- Add `base-address-shift` config flag
11+
1012
## [v0.31.5] - 2024-01-04
1113

1214
- `move` in `RegisterBlock::reg_iter` implementation (iterator of register/cluster array)

‎src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct Config {
2828
pub reexport_core_peripherals: bool,
2929
pub reexport_interrupt: bool,
3030
pub ident_formats: IdentFormats,
31+
pub base_address_shift: u64,
3132
}
3233

3334
#[allow(clippy::upper_case_acronyms)]

‎src/generate/peripheral.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
4040
let span = Span::call_site();
4141
let p_ty = ident(&name, &config.ident_formats.peripheral, span);
4242
let name_str = p_ty.to_string();
43-
let address = util::hex(p.base_address);
43+
let address = util::hex(p.base_address + config.base_address_shift);
4444
let description = util::respace(p.description.as_ref().unwrap_or(&p.name));
4545

4646
let mod_ty = name.to_snake_case_ident(span);
@@ -83,7 +83,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
8383
let description = pi.description.as_deref().unwrap_or(&p.name);
8484
let p_ty = ident(name, &config.ident_formats.peripheral, span);
8585
let name_str = p_ty.to_string();
86-
let address = util::hex(pi.base_address);
86+
let address = util::hex(pi.base_address + config.base_address_shift);
8787
let p_snake = name.to_sanitized_snake_case();
8888
snake_names.push(p_snake.to_string());
8989
let mut feature_attribute_n = feature_attribute.clone();

‎src/main.rs

+11
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ fn run() -> Result<()> {
199199
.action(ArgAction::SetTrue)
200200
.help("Reexport interrupt macro from cortex-m-rt like crates"),
201201
)
202+
.arg(
203+
Arg::new("base_address_shift")
204+
.short('b')
205+
.long("base-address-shift")
206+
.alias("base_address_shift")
207+
.action(ArgAction::Set)
208+
.help("Add offset to all base addresses on all peripherals in the SVD file.")
209+
.long_help("Add offset to all base addresses on all peripherals in the SVD file.
210+
Useful for soft-cores where the peripheral address range isn't necessarily fixed.
211+
Ignore this option if you are not building your own FPGA based soft-cores."),
212+
)
202213
.arg(
203214
Arg::new("log_level")
204215
.long("log")

0 commit comments

Comments
 (0)