hence the default arguments. when calling from inside ISACaller
it is best to use call_trap()
"""
- log("TRAP:", hex(trap_addr), hex(self.namespace['MSR'].value))
+ # https://bugs.libre-soc.org/show_bug.cgi?id=859
+ kaivb = self.spr['KAIVB'].value
+ msr = self.namespace['MSR'].value
+ log("TRAP:", hex(trap_addr), hex(msr), "kaivb", hex(kaivb))
# store CIA(+4?) in SRR0, set NIA to 0x700
# store MSR in SRR1, set MSR to um errr something, have to check spec
# store SVSTATE (if enabled) in SVSRR0
self.spr['SRR0'].value = self.pc.CIA.value
- self.spr['SRR1'].value = self.namespace['MSR'].value
+ self.spr['SRR1'].value = msr
if self.is_svp64_mode:
self.spr['SVSRR0'] = self.namespace['SVSTATE'].value
- self.trap_nia = SelectableInt(trap_addr, 64)
+ self.trap_nia = SelectableInt(trap_addr | (kaivb&~0x1fff), 64)
self.spr['SRR1'][trap_bit] = 1 # change *copy* of MSR in SRR1
# set exception bits. TODO: this should, based on the address
class TrapTestCase(TestAccumulatorBase):
def case_1_kaivb(self):
+ # https://bugs.libre-soc.org/show_bug.cgi?id=859
lst = ["mtspr 850, 1", # KAIVB
"mfspr 2, 850",
]
initial_regs, initial_sprs,
initial_msr=msr)
+ def case_2_kaivb_test(self):
+ # https://bugs.libre-soc.org/show_bug.cgi?id=859
+ # sets KAIVB to 1<<13 then deliberately causes exception.
+ # PC expected to jump to (1<<13)|0x700 *NOT* 0x700 as usual
+ lst = ["mtspr 850, 1", # KAIVB
+ "tbegin.", # deliberately use illegal instruction
+ ]
+ initial_regs = [0] * 32
+ initial_regs[1] = 1<<13
+ initial_sprs = {'KAIVB': 0x12345678,
+ }
+ msr = 0xa000000000000003
+ e = ExpectedState(pc=0x2700)
+ e.intregs[1] = 1<<13
+ e.msr = 0xa000000000000003 # TODO, not actually checked
+ self.add_case(Program(lst, bigendian),
+ initial_regs, initial_sprs,
+ initial_msr=msr,
+ expected=e)
+
def case_0_hrfid(self):
lst = ["hrfid"]
initial_regs = [0] * 32