Skip to content

Commit 1d68923

Browse files
committed
Merge branch 'dev' of https://github.com/cla7aye15I4nd/qiling into dev
2 parents f058e67 + b1b3e73 commit 1d68923

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

qiling/arch/cortex_m.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ def __exit__(self, *exc):
5454
else:
5555
self.ql.reg.write(reg, val)
5656

57+
<<<<<<< HEAD
5758
if self.ql.verbose >= QL_VERBOSE.DISASM:
5859
self.ql.log.info('Exit from interrupt')
60+
=======
61+
if self.ql.verbose >= QL_VERBOSE.DISASM:
62+
self.ql.log.info('Exit from interrupt')
63+
>>>>>>> b1b3e73119859b104e413ca68091f0cbe53e70e1
5964

6065
class QlArchCORTEX_M(QlArchARM):
6166
def __init__(self, ql):
@@ -111,6 +116,7 @@ def is_handler_mode(self):
111116
def using_psp(self):
112117
return not self.is_handler_mode() and (self.ql.reg.read('control') & CONTROL.SPSEL) > 0
113118

119+
<<<<<<< HEAD
114120
def handle_interupt(self, IRQn):
115121
basepri = self.ql.reg.read('basepri') & 0xf0
116122
if basepri and basepri <= self.ql.hw.nvic.get_priority(IRQn):
@@ -137,3 +143,34 @@ def handle_interupt(self, IRQn):
137143
self.ql.reg.write('lr', exc_return)
138144

139145
self.ql.emu_start(self.ql.arch.get_pc(), 0, count=0xffffff)
146+
=======
147+
def handle_interupt(self, IRQn):
148+
@QlInterruptContext(self.ql)
149+
def exec_interupt():
150+
if IRQn > IRQ.HARD_FAULT and (self.ql.reg.read('primask') & 0x1):
151+
return
152+
153+
if IRQn != IRQ.NMI and (self.ql.reg.read('faultmask') & 0x1):
154+
return
155+
156+
basepri = self.ql.reg.read('basepri') & 0xf0
157+
if basepri != 0 and basepri <= self.ql.hw.nvic.get_priority(IRQn):
158+
return
159+
160+
if self.ql.verbose >= QL_VERBOSE.DISASM:
161+
self.ql.log.debug(f'Handle the IRQn: {IRQn}')
162+
163+
isr = IRQn + 16
164+
offset = isr * 4
165+
166+
entry = self.ql.mem.read_ptr(offset)
167+
exc_return = 0xFFFFFFFD if self.ql.arch.using_psp() else 0xFFFFFFF9
168+
169+
self.ql.reg.write('ipsr', isr)
170+
self.ql.reg.write('pc', entry)
171+
self.ql.reg.write('lr', exc_return)
172+
173+
self.ql.emu_start(self.ql.arch.get_pc(), 0, count=0xffffff)
174+
175+
exec_interupt()
176+
>>>>>>> b1b3e73119859b104e413ca68091f0cbe53e70e1

0 commit comments

Comments
 (0)