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

Interrupt Support #230

Open
Wuerfel21 opened this issue Mar 19, 2022 · 1 comment
Open

Interrupt Support #230

Wuerfel21 opened this issue Mar 19, 2022 · 1 comment

Comments

@Wuerfel21
Copy link
Contributor

Just some brainstorming...

  • Hand-written interrupt handlers should already work, as long as they push/pop the registers they use (and as long as they are lower priority than any high-level interrupt, it really doesn't matter which registers) and don't touch the CORDIC. Just isn't a documented feature / slightly cumbersome.
  • High-level interrupt handlers would need a little more work
    • Need a cog routine that saves/restores necessary state and adapters IRQ calls to normal calls
    • CORDIC state needs saving
      • I think it can be done (can re-inject old saved results into pipeline using QROTATE)
    • pa/pb need to be saved (perhaps ptrb, too?)
    • localXX doesn't need saving 👍
    • _varXX needs saving
    • argXX and resultXX need saving
    • objptr needs saving (and should be set to some useful value before entering the handler function)
    • ptr_* ???
      • maybe just change P2 codegen to not need these. Could generate a LOC instruction instead, which would also be smaller and faster than the ADD/SUB sequences.
    • other misc. registers need saving: COUNT_,RETADDR_,fp,muldiva_, etc
    • FCACHE...
      • I guess fcache_tmpb_ contains the current FCACHE content pointer, so if size was also memo'd somewhere, we could just preserve those values and reload it if the interrupt handler loaded something else
        • I guess Spin2-style inline ASM can self-mutate. I guess these need special treatment (i.e. IRQ adapter needs to always dump FCACHE to stack and restore.) Perhaps have a separate FCACHE_LOAD_ version that clears fcache_tmpb_, which signals this to the adapter.
        • wait, FCACHE isn't actually cached? (i.e. not reloaded every time)

I guess the first steps would be getting rid of ptr_* (because that'd just improve code quality in general) and to change the way cog locations are allocated such that most of the volatile ones are a nice block that can be pushed and popped in one go, with labels either end.

@totalspectrum
Copy link
Owner

Some of these problems would be simplified if we had a "stack only" compilation mode where all functions are compiled with locals and arguments on the stack. Performance would be horrible, but that may be the price for interrupt support.

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