Skip to content
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

RAM-based interrupt vector tables #321

Merged
merged 7 commits into from
Aug 6, 2022
Merged

RAM-based interrupt vector tables #321

merged 7 commits into from
Aug 6, 2022

Conversation

9names
Copy link
Member

@9names 9names commented Mar 27, 2022

To improve performance for interrupts and allow for dynamically hooking interrupt vectors at runtime, provide some facilities for creating and using interrupt vector tables.
This should also increase what we can do with multicore.

This code is currently completely untested.

rp2040-hal/src/multicore.rs Outdated Show resolved Hide resolved
rp2040-hal/src/multicore.rs Outdated Show resolved Hide resolved
@jannic
Copy link
Member

jannic commented May 30, 2022

Didn't test the code either, but it looks sensible.
Maybe find a better place, though? I don't think it's multicore-related.

@9names
Copy link
Member Author

9names commented Jun 1, 2022

I have tested it since I wrote the first comment, but not in a while. It explodes.
Haven't gotten around to working out why yet.

I don't think it's multicore-related.

You're right. I had written this to help out with a multicore experiment so that is what was on my mind.
I'll need to consider where it should go.

@9names
Copy link
Member Author

9names commented Jul 20, 2022

I've rebased this and written an example testing it.
It seems to work fine now, despite my previous comment stating that it exploded.
Not sure if if needs a fence after the VTOR copy.

Also decided to go back to just copying the 192 bytes that are used by the table entries instead of core::mem::size_of::<VectorTable>().
I still don't have a good mental model of whether the padding bytes (256 bytes - 192) will be used by other static variables, so avoiding writing to them seems the safest option.

@9names 9names marked this pull request as ready for review July 20, 2022 09:17
@9names 9names changed the title WIP: RAM-based interrupt vector tables RAM-based interrupt vector tables Jul 20, 2022
@jannic
Copy link
Member

jannic commented Jul 20, 2022

I still don't have a good mental model of whether the padding bytes (256 bytes - 192) will be used by other static variables, so avoiding writing to them seems the safest option.

This seems to be an open question:

@9names
Copy link
Member Author

9names commented Jul 24, 2022

Thanks for those threads. I think the answer (right now) is that the padding bytes are unused.
And, it doesn't seem like any existing target will support stride != size, so that should hold in the future.
Would be nice to have a way to overalign the start of an array to avoid this though - maybe we'll get magic syntax for that some day but I don't want it so badly that I'll push for it.

@9names 9names merged commit 2bbc52f into rp-rs:main Aug 6, 2022
@9names 9names deleted the ram-vtor branch August 6, 2022 04:58
ExplodingWaffle pushed a commit to ExplodingWaffle/rp-hal that referenced this pull request Aug 14, 2022
* Add struct VectorTable to represent an interrupt vector table

* Add member function to VectorTable to initialise based on the current Interrupt Vector Table from VTOR

* Add member function to VectorTable to register an extern "C" function to call on interrupt

* Add example using VectorTable to demonstrate initialisation and interrupt function registration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants