Skip to content

Commit 5c99af9

Browse files
committed
Fix the interrupt details
1 parent 87238d8 commit 5c99af9

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

qiling/arch/cortex_m.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,34 @@ def init_context(self):
113113
self.ql.reg.write('pc' , self.ql.mem.read_ptr(0x4))
114114

115115
def soft_interrupt_handler(self, ql, intno):
116-
if intno == EXCP.SWI:
117-
ql.hw.nvic.set_pending(IRQ.SVCALL)
118-
119-
elif intno == EXCP.EXCEPTION_EXIT:
120-
ql.emu_stop()
121-
122-
else:
116+
forward_mapper = {
117+
EXCP.UDEF : IRQ.HARD_FAULT, # undefined instruction
118+
EXCP.SWI : IRQ.SVCALL, # software interrupt
119+
EXCP.PREFETCH_ABORT : IRQ.HARD_FAULT,
120+
EXCP.DATA_ABORT : IRQ.HARD_FAULT,
121+
EXCP.EXCEPTION_EXIT : IRQ.NOTHING,
122+
# EXCP.KERNEL_TRAP : IRQ.NOTHING,
123+
# EXCP.HVC : IRQ.NOTHING,
124+
# EXCP.HYP_TRAP : IRQ.NOTHING,
125+
# EXCP.SMC : IRQ.NOTHING,
126+
# EXCP.VIRQ : IRQ.NOTHING,
127+
# EXCP.VFIQ : IRQ.NOTHING,
128+
# EXCP.SEMIHOST : IRQ.NOTHING,
129+
EXCP.NOCP : IRQ.USAGE_FAULT, # v7M NOCP UsageFault
130+
EXCP.INVSTATE : IRQ.USAGE_FAULT, # v7M INVSTATE UsageFault
131+
EXCP.STKOF : IRQ.USAGE_FAULT, # v8M STKOF UsageFault
132+
# EXCP.LAZYFP : IRQ.NOTHING,
133+
# EXCP.LSERR : IRQ.NOTHING,
134+
EXCP.UNALIGNED : IRQ.USAGE_FAULT, # v7M UNALIGNED UsageFault
135+
}
136+
137+
ql.emu_stop()
138+
139+
try:
140+
handle = forward_mapper.get(intno)
141+
if handle != IRQ.NOTHING:
142+
ql.hw.nvic.set_pending(handle)
143+
except IndexError:
123144
raise QlErrorNotImplemented(f'Unhandled interrupt number ({intno})')
124145

125146
def hard_interrupt_handler(self, ql, intno):

0 commit comments

Comments
 (0)