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

Unified interrupt handler interface #12

Open
dylanmckay opened this issue Nov 7, 2018 · 4 comments
Open

Unified interrupt handler interface #12

dylanmckay opened this issue Nov 7, 2018 · 4 comments

Comments

@dylanmckay
Copy link
Member

CC #9

Our interrupt handler story isn't super great; we require users to write their own interrupt vector table (IVT) in assembly, and then they define a set of pub unsafe extern "avr-interrupt" fn <interrupt handler symbol name>() { } that the IVT points to.

Here's an example program that installs interrupt handlers.

We should come up with a single, unified method of defining interrupt handlers. All AVR-Rust programs should use the same interrupt handler function names, by convention. This is similar to AVR-GCC, which always uses the same function names, although GCC has much more abbreviated, hard-to-understand names. Let's be more descriptive.

@dylanmckay
Copy link
Member Author

For example, we could write an avr-interrupts crate or something to do this. It is probably not a good idea baking this into the avr-rust/rust compiler itself because that will make the upstream effort much more difficult.

@dylanmckay
Copy link
Member Author

Whatever method we come up with, we need to be able to guarantee that the interrupt vector table will be linked before any other object file in any AVR-Rust program. The IVT always sits at the very first byte of a raw binary AVR program.

@shepmaster
Copy link
Member

we require users to write their own interrupt vector table (IVT) in assembly

I don't think this is strictly true if you are linking with the avr-gcc runtime glue. AIUI, in that case, that code provides the IVT and other routines like "copy static data from flash to memory".

avr-interrupts crate or something to do this

I agree. Theoretically, people will want to do their own route for everything (hello, me) and baking anything in will make them annoyed.

the interrupt vector table will be linked before any other object file in any AVR-Rust program.

I think the safe way to do this is via a linker script. You can see mine. The table is stored in a special section and then linked first in the code.

@shepmaster
Copy link
Member

A related aspect that we will need to deal with is model-specific aspects. For example, this linker script bakes in the amount of memory available. It also has a fixed set of interrupts which change depending on the model of processor.

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

No branches or pull requests

2 participants