rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
697 stars 150 forks source link

feat: configurable link section attribute for irqs #718

Closed sethp closed 1 year ago

sethp commented 1 year ago

This change introduces a new config field that allows svd2rust to target which linker sections get assigned to the __INTERRUPTS static, with reasonable defaults.

Previously on RISC-V, the choice was always left up to the compiler, and it seemed to always pick .rodata. Unfortunately, in my context, that meant placing the LUT in a memory range that had a lot of highly variable latency, which cost not just time but predictability in servicing interrupts.

With this change in place, I'm able to target a particular section (e.g. .data, or .trap.rodata) for the placement of the static, which grants more granular control over the ultimate loaded memory address.

For the full details about the problem, please see: https://github.com/esp-rs/esp-hal/pull/534/commits/e29f3d547dc210e1b73313be6053a2122239a467

burrbull commented 1 year ago

I hope this is backward compatible?

sethp commented 1 year ago

Oh, great point: the code generator changes are in the sense that passing None for that parameter (or not setting a value, which should default to None) doesn't change the generated code.

Using the new parameter may not be backwards compatible, depending on what link section is being set: as long as the new section gets output in some part of the resulting binary it sure could be, but it's somewhat easy to rely on a particular layout, either accidentally or on purpose.

burrbull commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here. For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.