Update spec and register offset for interrupts

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-03-09 18:42:31 -04:00
parent 8c4a9991fd
commit 3522b3d0cd
2 changed files with 12 additions and 7 deletions

View File

@@ -169,6 +169,10 @@ impl State {
Ok(slice)
}
// stack size of 288 - yowza
// Maybe we don't need 32 registers... this works out to 288
const INTERRUPT_REG_SPACE: u64 = (R31 - R00 + 4) as u64 * 8;
/// Invoke an interrupt.
pub fn interrupt(&mut self, return_ip: u64, index: usize, aux: u64) -> Result<u64> {
assert!(index < IVT_LENGTH, "invalid interrupt index");
@@ -192,8 +196,9 @@ impl State {
self.push(Source::Reg(reg))?;
}
let sp = self.sp();
self.set_reg_unchecked(FP, sp - 48);
self.set_reg_unchecked(FP, sp - Self::INTERRUPT_REG_SPACE);
self.set_reg_unchecked(R00, index as u64);
self.set_reg_unchecked(R01, aux);
@@ -203,7 +208,7 @@ impl State {
/// Exit/return from the current interrupt.
pub fn exit_interrupt(&mut self) -> Result<u64> {
let fp = self.fp();
let sp = fp + 48;
let sp = fp + Self::INTERRUPT_REG_SPACE;
self.set_reg_unchecked(SP, sp);