Extend how interrupts are reported to the main execution loop

Some things that were previously hard VM-level errors are now handled by
interrupts. While this is relatively easy to handle, I was wanting a
little more structure for the error types - so, errors that should
invoke an interrupt are passed along in their own structure in a
VmError::Interrupt variant. If an error is raised during the tick()
phase of execution that would cause an interrupt, that interrupt is
intercepted and the VM continues.

The State::interrupt() function also will catch double faults and triple
faults, with a triple fault being its own variant in the VmError
structure (so it cannot be intercepted as an interrupt by accident).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-03-12 16:56:20 -04:00
parent cb75bf59e0
commit bff9220fb1
8 changed files with 146 additions and 52 deletions

8
vm.md
View File

@@ -343,12 +343,12 @@ will unconditionally halt the machine.
* Double fault
* Interrupt vector: 0x00
* Auxiliary:
* Auxiliary: The interrupt vector that was being invoked that caused the fault.
* An error state interrupt occurred while already handling an error state interrupt
* Invalid opcode
* Illegal instruction
* Interrupt vector: 0x01
* Auxiliary: N/A
* Attempted to invoke an illegal opcode
* Auxiliary: Memory address where illegal instruction is located
* Attempted to execute a malformed instruction
* Illegal memory address
* Interrupt vector: 0x02
* Auxiliary: Memory address causing the interrupt