start interrupt timer on start
This commit is contained in:
parent
a5a49c3292
commit
3493dfa219
@ -38,31 +38,8 @@ static inline int64_t systick_scale(SysTickState *s)
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
|
||||
/* Begin LibAFL instrumentation */
|
||||
extern void libafl_send_irq(int irqn);
|
||||
extern int64_t libafl_get_clock( void );
|
||||
volatile unsigned int libafl_int_offset = 0;
|
||||
volatile bool libafl_int_done = false;
|
||||
/* This can be moved to a helper function later */
|
||||
inline void libafl_exec_systick_hook(void);
|
||||
inline void libafl_exec_systick_hook(void)
|
||||
{
|
||||
if (libafl_int_offset!=0 && libafl_int_offset) {
|
||||
if (libafl_get_clock() >= libafl_int_offset) {
|
||||
if (!libafl_int_done) {
|
||||
libafl_int_done = true;
|
||||
libafl_send_irq(0);
|
||||
}
|
||||
} else {
|
||||
libafl_int_done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
static void systick_timer_tick(void *opaque)
|
||||
{
|
||||
libafl_exec_systick_hook();
|
||||
/* End LibAFL instrumentation */
|
||||
SysTickState *s = (SysTickState *)opaque;
|
||||
|
||||
trace_systick_timer_tick();
|
||||
@ -270,3 +247,28 @@ static void armv7m_systick_register_types(void)
|
||||
}
|
||||
|
||||
type_init(armv7m_systick_register_types)
|
||||
|
||||
/* Begin LibAFL instrumentation */
|
||||
extern void libafl_send_irq(int irqn);
|
||||
volatile unsigned int libafl_int_offset = 0;
|
||||
static ptimer_state* mytimer;
|
||||
/* This can be moved to a helper function later */
|
||||
static void libafl_timed_int_hook(void*);
|
||||
static void libafl_timed_int_hook(void* arg)
|
||||
{
|
||||
libafl_send_irq(0);
|
||||
}
|
||||
void libafl_start_int_timer( void );
|
||||
void libafl_start_int_timer( void ) {
|
||||
if (libafl_int_offset==0) {return;}
|
||||
if (!mytimer) {
|
||||
mytimer = ptimer_init(&libafl_timed_int_hook, NULL, 0);
|
||||
}
|
||||
ptimer_transaction_begin(mytimer);
|
||||
ptimer_stop(mytimer);
|
||||
ptimer_set_period(mytimer, libafl_int_offset);
|
||||
ptimer_set_count(mytimer, 8);
|
||||
ptimer_run(mytimer, 1);
|
||||
ptimer_transaction_commit(mytimer);
|
||||
}
|
||||
/* End LibAFL instrumentation */
|
@ -66,8 +66,14 @@ void libafl_phys_read(vaddr, uint8_t*, int);
|
||||
void libafl_phys_write(vaddr, uint8_t*, int);
|
||||
int64_t libafl_get_clock( void );
|
||||
|
||||
#ifdef TARGET_ARM
|
||||
extern void libafl_start_int_timer(void);
|
||||
#endif
|
||||
void libafl_qemu_main_loop( void )
|
||||
{
|
||||
#ifdef TARGET_ARM
|
||||
libafl_start_int_timer();
|
||||
#endif
|
||||
vm_start();
|
||||
qemu_main_loop();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user