Closed hug-dev closed 4 years ago
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @adamgreig (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
Please see the contribution instructions for more information.
With this then one can do:
let peripherals = Peripherals::take().unwrap();
let mut sau = peripherals.SAU;
// Those symbols come from the linker file.
extern "C" {
static mut __veneer_base: u32;
static mut __veneer_limit: u32;
}
let base_nsc = unsafe { core::mem::transmute::<&mut u32, u32>(&mut __veneer_base) };
let limit_nsc = unsafe { core::mem::transmute::<&mut u32, u32>(&mut __veneer_limit) };
// Non-Secure Callable area
sau.set_region(2, SauRegion {
base_address: base_nsc,
limit_address: limit_nsc | 0x1F,
attribute: SauRegionAttribute::NonSecureCallable,
}).unwrap();
sau.enable();
to configure its Non-Secure Callable section 🚀
Ok I did the change, I hope this is what you were expecting. I think this is fine to align everything to 4 bytes as veneers are 32 bits long (two thumb instructions). Only the start is aligned to 32 bytes because of SAU requirements.
The veneers are for now only generated by the Arm GNU linker when it spots an entry function (one that was decorated with the cmse_nonsecure_entry attribute). Adding this section will allow to configure the SAU to make this section Non-Secure Callable.
Doing tests locally I could not see any warnings if this section was empty so I think this is fine. It is highly specific to the GNU toolchain so maybe you would want some preprocessing directive and
cfg
options which I am happy to add.There is documentation for the section name at the end of this page.
It needs to be aligned on 32 bytes as a requirement from the Security Attribute Unit.