[kernel] Add kernel and user mode divide by zero handling #1969
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds handler for divide by zero and divide overflow hardware exception thrown in DIV or IDIV instructions.
Solves problem identified in Mellvik/TLVC#71 (comment).
If the fault occurs from a user application, a SIGABRT signal (ELKS has no SIGFPE) is sent, which usually causes program termination. For kernel faults, a divide by zero panic message is shown and the kernel stops executing. Restarting any code after a DIV exception turns out to be quite complicated, as the hardware fault pushes a different CS:IP depending on whether the CPU is prior to an 80286 or not.
Also removed/rewrote "IRQ allocation" scheme used in irq.c as overly complicated, which saves ~100 bytes in kernel. It is now easy to add any other hardware trap/fault handler to the kernel should that be wanted.
Removed
intr_count
global from irqtab.S as unneeded, the_gint_count
variable already tracks kernel reentry.