-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add set_vector_table_offset() #1579
Conversation
arch/cortex-m/src/scb.rs
Outdated
@@ -54,3 +54,8 @@ pub unsafe fn reset() { | |||
let reset = (0x5FA << 16) | (aircr & (0x7 << 8)) | (1 << 2); | |||
SCB.aircr.set(reset); | |||
} | |||
|
|||
/// relocate interrupt vector table | |||
pub unsafe fn set_vector_table_offset(offset: u32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offset
is really an address, correct? Should the argument be a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VTOR is Vector Table Offset Register
Not sure if the offset
is an address or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARM specifies it as an offset, but that offset appears to always be from 0. I think it is more clear of an API if we take a pointer as an argument, which is the location the vector table is now at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still new to Rust, not sure what pointer type should be used? *const c_void
or *const u32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably *const ()
.
Thanks, and this is a useful function. I checked how the tock bootloader works and it just uses assembly to set the new vector table, so it would not compile for non cortex-m boards currently. Along those lines, we eventually need some mechanism to expose this functionality outside of the arch/ crate so that a generic bootloader could use. And then just as a side note, I ask that you do not truncate the PR template because sometimes there are documentation needs that are not immediately obvious. In this case we do not need to update documentation, however. |
One thing we'll need to think about at some point is that cortex-m0 does not have a Right now we just don't export the SCB to the m0 crate, but this is really the same problem that we're running into with nrf variants as well... |
I thought Tock can not be run on a cortex-m0 microcontroller which doesn't have a MPU. Is this right? |
I have Tock running on M0 mostly for testing and experimentation purposes. Yes, there is no MPU, so you won't get hardware memory protection for user processes. All that is needed is to do the following in
The other (annoying) issue with M0 is the lack of atomics. I am glad to see OpenTitan including atomic support into its core. |
Yeah I don't think we need to base any Tock design decisions on cortex-m0, it is just too constrained. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a pointer API makes more sense and is clearer for users. Let me know if you think it is better to expose the ARM interface.
I agree with @bradjc that the parameter should be a pointer. Otherwise, I think this is an easy merge once that's fixed. |
when using a bootloader, tock os may need to relocate interrupt vector table, then use this function to do that
as @alevy suggested, changed it to An example to use it:
|
bors r+ |
Build succeeded |
Now the script supports more flashing methods: - JLink (with tockloader) - OpenOCD (with tockloader) - pyOCD - Nordic DFU - none (will produce an IntelHex file) Also merged the contributions from: - Yihui Xiong to support the Makerdiary USB dongle board - Dennis Geurts to support Nordic DFU Doc updated accordingly. Imported 2 patches for Tock kernel: - 06-add-set_vector_table_offset.patch (upstream tock/tock#1579) - 07-nrf52-bootloader.patch (upstream tock/tock#1681)
Now the script supports more flashing methods: - JLink (with tockloader) - OpenOCD (with tockloader) - pyOCD - Nordic DFU - none (will produce an IntelHex file) Also merged the contributions from: - Yihui Xiong to support the Makerdiary USB dongle board - Dennis Geurts to support Nordic DFU Doc updated accordingly. Imported 2 patches for Tock kernel: - 06-add-set_vector_table_offset.patch (upstream tock/tock#1579) - 07-nrf52-bootloader.patch (upstream tock/tock#1681)
Now the script supports more flashing methods: - JLink (with tockloader) - OpenOCD (with tockloader) - pyOCD - Nordic DFU - none (will produce an IntelHex file) Also merged the contributions from: - Yihui Xiong to support the Makerdiary USB dongle board - Dennis Geurts to support Nordic DFU Doc updated accordingly. Imported 2 patches for Tock kernel: - 06-add-set_vector_table_offset.patch (upstream tock/tock#1579) - 07-nrf52-bootloader.patch (upstream tock/tock#1681)
Now the script supports more flashing methods: - JLink (with tockloader) - OpenOCD (with tockloader) - pyOCD - Nordic DFU - none (will produce an IntelHex file) Also merged the contributions from: - Yihui Xiong to support the Makerdiary USB dongle board - Dennis Geurts to support Nordic DFU Doc updated accordingly. Imported 2 patches for Tock kernel: - 06-add-set_vector_table_offset.patch (upstream tock/tock#1579) - 07-nrf52-bootloader.patch (upstream tock/tock#1681)
when using a bootloader, tock os may need to relocate interrupt
vector table, then use this function to do that.
See the discussion at google/OpenSK#3
Pull Request Overview
This pull request adds
add set_vector_table_offset
function to relocate interrupt vector table.Testing Strategy
TODO
TODO or Help Wanted
N/A
Documentation Updated
/docs
, or no updates are required.Formatting
make formatall
.