Add IVT register and interrupt module
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
19
src/libvm/src/interrupt.rs
Normal file
19
src/libvm/src/interrupt.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
macro_rules! interrupts {
|
||||||
|
{
|
||||||
|
$($variant:ident = $value:expr),* $(,)?
|
||||||
|
} => {
|
||||||
|
pub type IntVec = u8;
|
||||||
|
|
||||||
|
$(
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub const $variant: IntVec = $value;
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interrupts! {
|
||||||
|
DIVIDE_BY_ZERO = 0,
|
||||||
|
INVALID_OPCODE = 1,
|
||||||
|
ILLEGAL_MEMORY_ADDRESS = 2,
|
||||||
|
HARDWARE_EVENT = 3,
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ pub mod addr;
|
|||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod flags;
|
pub mod flags;
|
||||||
pub mod inst;
|
pub mod inst;
|
||||||
|
pub mod interrupt;
|
||||||
pub mod mem;
|
pub mod mem;
|
||||||
pub mod obj;
|
pub mod obj;
|
||||||
pub mod reg;
|
pub mod reg;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ dump "DUMP"
|
|||||||
%fp "REG_FP"
|
%fp "REG_FP"
|
||||||
%flags "REG_FLAGS"
|
%flags "REG_FLAGS"
|
||||||
%null "REG_NULL"
|
%null "REG_NULL"
|
||||||
|
%ivt "REG_IVT"
|
||||||
%status "REG_STATUS"
|
%status "REG_STATUS"
|
||||||
%r[0-9]{1,2} "REG_GENERAL"
|
%r[0-9]{1,2} "REG_GENERAL"
|
||||||
[a-zA-Z_][a-zA-Z0-9_]* "NAME"
|
[a-zA-Z_][a-zA-Z0-9_]* "NAME"
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ Reg -> Reg:
|
|||||||
| 'REG_FP' { FP }
|
| 'REG_FP' { FP }
|
||||||
| 'REG_FLAGS' { FLAGS }
|
| 'REG_FLAGS' { FLAGS }
|
||||||
| 'REG_NULL' { NULL }
|
| 'REG_NULL' { NULL }
|
||||||
|
| 'REG_IVT' { IVT }
|
||||||
| 'REG_STATUS' { STATUS }
|
| 'REG_STATUS' { STATUS }
|
||||||
| 'REG_GENERAL' {
|
| 'REG_GENERAL' {
|
||||||
let v = $1.expect("could not parse reg");
|
let v = $1.expect("could not parse reg");
|
||||||
|
|||||||
@@ -36,41 +36,44 @@ registers! {
|
|||||||
// Zero
|
// Zero
|
||||||
NULL = 4,
|
NULL = 4,
|
||||||
|
|
||||||
// General status code
|
// Interrupt vector table pointer
|
||||||
STATUS = 5,
|
IVT = 5,
|
||||||
|
|
||||||
R00 = 6,
|
// General status code
|
||||||
R01 = 7,
|
STATUS = 6,
|
||||||
R02 = 8,
|
|
||||||
R03 = 9,
|
R00 = 7,
|
||||||
R04 = 10,
|
R01 = 8,
|
||||||
R05 = 11,
|
R02 = 9,
|
||||||
R06 = 12,
|
R03 = 10,
|
||||||
R07 = 13,
|
R04 = 11,
|
||||||
R08 = 14,
|
R05 = 12,
|
||||||
R09 = 15,
|
R06 = 13,
|
||||||
R10 = 16,
|
R07 = 14,
|
||||||
R11 = 17,
|
R08 = 15,
|
||||||
R12 = 18,
|
R09 = 16,
|
||||||
R13 = 19,
|
R10 = 17,
|
||||||
R14 = 20,
|
R11 = 18,
|
||||||
R15 = 21,
|
R12 = 19,
|
||||||
R16 = 22,
|
R13 = 20,
|
||||||
R17 = 23,
|
R14 = 21,
|
||||||
R18 = 24,
|
R15 = 22,
|
||||||
R19 = 25,
|
R16 = 23,
|
||||||
R20 = 26,
|
R17 = 24,
|
||||||
R21 = 27,
|
R18 = 25,
|
||||||
R22 = 28,
|
R19 = 26,
|
||||||
R23 = 29,
|
R20 = 27,
|
||||||
R24 = 30,
|
R21 = 28,
|
||||||
R25 = 31,
|
R22 = 29,
|
||||||
R26 = 32,
|
R23 = 30,
|
||||||
R27 = 33,
|
R24 = 31,
|
||||||
R28 = 34,
|
R25 = 32,
|
||||||
R29 = 35,
|
R26 = 33,
|
||||||
R30 = 36,
|
R27 = 34,
|
||||||
R31 = 37,
|
R28 = 35,
|
||||||
|
R29 = 36,
|
||||||
|
R30 = 37,
|
||||||
|
R31 = 38,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LAST_REG: Reg = 63;
|
pub const LAST_REG: Reg = 63;
|
||||||
|
|||||||
Reference in New Issue
Block a user