tosc-rs / mnemos

An Operating System for Building Small Computers
https://mnemos.dev
Apache License 2.0
234 stars 14 forks source link

PLIC refactors and performance improvements #312

Closed hawkw closed 3 months ago

hawkw commented 3 months ago

Currently, the interrupt vector dispatch code uses a linear search over the interrupt vector array by checking each vector's ID against the interrupt number being dispatched. This is inefficient; because we already generate the vector array in order, we can simply index into it, which is O(1) instead of O(ninterrupts). This commit changes the existing code to do that.

We can rely on the ordering being correct as it's generated by a const fn that should always output the same order. However, I've also added debug assertions that the index and ID match, just in case the table somehow gets corrupted or something. I don't think this is really that necessary, but it seemed nice to have.

hawkw commented 3 months ago

@jamesmunns I'd love to get your review on this, since I'm hacking up your code. Also, I haven't actually tested this on my D1 yet, so I should make sure it like, works.

hawkw commented 3 months ago

hmm, i flashed this change on my D1 and observed the following:

which kind of suggests that interrupt handling is broken.

however, the keyboard and SHARP display do seem to work. going to try flashing with a build from master and making sure we haven't just broken stuff on master too.

hawkw commented 3 months ago

hmm, i flashed this change on my D1 and observed the following:

* the UART doesn't seem to work (no output in crowtty)

* the blue blinky light is solid on rather than blinky

which kind of suggests that interrupt handling is broken.

however, the keyboard and SHARP display do seem to work. going to try flashing with a build from master and making sure we haven't just broken stuff on master too.

Update: nevermind, the "broken UART" was just "i was looking at the wrong USB TTY", and after rebasing onto `main I now see a proper blinkenlight. False alarm!