@@ -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
6065class 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