Closed hawkw closed 8 years ago
Just a quick note: The code from the blog post doesn't save registers yet, so it's only suitable for exception handlers that never return. However it should be possible to save the registers using naked functions. I think @eddyb has mentioned some ideas regarding this on twitter.
@phil-opp: yeah, I only skimmed your blog post and I'm only just now taking a peek at your exception-handling code, since I already had interrupts working and just wanted to see how you had done it. Now that we have naked functions, though, I imagine that pushing the registers can be moved to Rust code now (at least to inline assembly).
See 251119330f777f59d198b20af876645cba4b93e5 - not done yet but it's happening!
Our current interrupt handling architecture certainly works, but it is a bit of a mess. We have an assembly language file that makes an array of interrupt handler functions, but they all just call the same Rust function which then matches the interrupt ID and dispatches again. This is a mess.
The current approach has way too many moving parts, with ASM interrupt handlers getting dispatched to by the IDT but then all just jumping to the same God function (
handle_interrupt
) in Rust-land, which dispatches again based on the interrupt ID. It also doesn't help us to achieve our goal of using files ending in.asm
only in the boot sequence.Also, even though we have separate
handle_interrupt
andhandle_cpu_exception
functions, and separate macros in the assembly file for generating ASM handlers for exceptions and normal interrupts, we still dispatch CPU exceptions throughhandle_interrupt
. Even the namehandle_interrupt
is a problem: a function with a name that broad is probably a God function that needs to be broken apart.It seems to me we have several options. We could keep the current architecture, but try to do away with the assembly handlers by just sticking
handle_interrupt
andhandle_cpu_exception
directly into the IDT. In @phil-opp's recent blog post on interrupt handling, he just writes a separate Rust handler function for each interrupt and sticks them into his IDT. This might be a better way to go - it's simpler and gets rid of thehandle_interrupt
God function.