Polish the VM exception definitions, add double faults, update exception order
* Exception definition is a little more comprehensive * Add error state exceptions including double fault * Exception numbers are now roughly in the order of their importance Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -14,10 +14,16 @@ macro_rules! interrupts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interrupts! {
|
interrupts! {
|
||||||
DIVIDE_BY_ZERO = 0,
|
// Error state exceptions
|
||||||
INVALID_OPCODE = 1,
|
|
||||||
ILLEGAL_MEMORY_ADDRESS = 2,
|
DOUBLE_FAULT = 0x00,
|
||||||
HARDWARE_EVENT = 3,
|
INVALID_OPCODE = 0x01,
|
||||||
|
ILLEGAL_MEMORY_ADDRESS = 0x02,
|
||||||
|
DIVIDE_BY_ZERO = 0x03,
|
||||||
|
|
||||||
|
// General exceptions
|
||||||
|
|
||||||
|
//IO_EVENT = 0x80,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const IVT_LENGTH: usize = 512;
|
pub const IVT_LENGTH: usize = 512;
|
||||||
|
|||||||
52
vm.md
52
vm.md
@@ -322,34 +322,50 @@ the above actions occur in reverse:
|
|||||||
|
|
||||||
## Exceptions
|
## Exceptions
|
||||||
|
|
||||||
The first 256 interrupt vectors are reserved for CPU and hardware-sourced events - these are known
|
The first 256 interrupt vectors are reserved for CPU and I/O-sourced events - these are known as
|
||||||
as exceptions. Exceptions may occur for a number of reasons:
|
exceptions. Likewise, the first 128 exceptions are error state exceptions, with the remaining 128
|
||||||
|
being used for general exceptions.
|
||||||
|
|
||||||
* Illegal operation attempted, e.g. divide by zero or accessing protected memory
|
### Error state exceptions
|
||||||
* Illegal operation attempted while handling an interrupt (double fault)
|
|
||||||
* A hardware event occurred, e.g. a timer tick
|
|
||||||
|
|
||||||
The following list defines all exceptions that the CPU may invoke. All other vectors in 0-255 not
|
Error state exceptions occur when an instruction attempts to perform illegal operation,
|
||||||
defined in this table are reserved and may be used in the future.
|
such as attempting to read an out-of-bounds memory address or attempting to execute an invalid
|
||||||
|
opcode. Error state exceptions may be caught and handled, just like any other interrupt.
|
||||||
|
|
||||||
* Divide by zero
|
#### Double fault and triple fault
|
||||||
* Interrupt vector: 0
|
|
||||||
* Auxiliary: N/A
|
If, while already handling an error state exception, and a second error state exception is raised, a
|
||||||
* Invoked upon a divide-by-zero
|
double fault is invoked. You may handle a double fault like any exception and attempt to repair the
|
||||||
|
situation. If yet another exception is raised, the CPU will invoke a triple fault. A triple fault
|
||||||
|
will unconditionally halt the machine.
|
||||||
|
|
||||||
|
### Error state exceptions (vectors 0x00-0x0f)
|
||||||
|
|
||||||
|
* Double fault
|
||||||
|
* Interrupt vector: 0x00
|
||||||
|
* Auxiliary:
|
||||||
|
* An error state interrupt occurred while already handling an error state interrupt
|
||||||
* Invalid opcode
|
* Invalid opcode
|
||||||
* Interrupt vector: 1
|
* Interrupt vector: 0x01
|
||||||
* Auxiliary: N/A
|
* Auxiliary: N/A
|
||||||
* Attempted to invoke an illegal opcode
|
* Attempted to invoke an illegal opcode
|
||||||
* Illegal memory address
|
* Illegal memory address
|
||||||
* Interrupt vector: 2
|
* Interrupt vector: 0x02
|
||||||
* Auxiliary: Memory address causing the interrupt
|
* Auxiliary: Memory address causing the interrupt
|
||||||
* Attempted to access a memory address in an illegal way - either it's out of bounds or is
|
* Attempted to access a memory address in an illegal way - either it's out of bounds or is
|
||||||
protected in some way.
|
protected in some way.
|
||||||
* Hardware event
|
* Divide by zero
|
||||||
* Interrupt vector: 3
|
* Interrupt vector: 0x03
|
||||||
* Auxiliary: Pointer to the hardware event structure.
|
* Auxiliary: N/A
|
||||||
* A hardware device has an event that needs attention.
|
* Invoked upon a divide-by-zero
|
||||||
* Interrupt vector 4-255: Reserved for future use
|
* Remaining error states below 0x80 are reserved for future use.
|
||||||
|
|
||||||
|
### General exceptions (vectors 0x80-0xff)
|
||||||
|
* I/O event
|
||||||
|
* Interrupt vector: 0x80
|
||||||
|
* Auxiliary: Pointer to the I/O event structure.
|
||||||
|
* An I/O device has an event that needs attention.
|
||||||
|
* NOTE: This will probably be removed.
|
||||||
|
|
||||||
# Binary object format
|
# Binary object format
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user