Skip to content

Commit 155dae5

Browse files
committed
AVR: fix selection and validation of CPU model.
Signed-off-by: Glenn Baker <[email protected]>
1 parent 04c823c commit 155dae5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

qemu/target/avr/cpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ static const AVRCPUInfo *avr_cpu_info_get(int cpu_model)
368368
return NULL;
369369
}
370370

371+
int avr_cpu_model_valid(int cpu_model)
372+
{
373+
return avr_cpu_info_get(cpu_model) != NULL;
374+
}
375+
371376
#if 0
372377
static void avr_cpu_list_entry(gpointer data, gpointer user_data)
373378
{

qemu/target/avr/unicorn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ void avr_reg_reset(struct uc_struct *uc);
2323

2424
void avr_uc_init(struct uc_struct *uc);
2525

26+
int avr_cpu_model_valid(int cpu_model);
27+
2628
#endif /* UC_QEMU_TARGET_AVR_H */

uc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,11 @@ uc_err uc_ctl(uc_engine *uc, uc_control_type control, ...)
27142714
err = UC_ERR_ARG;
27152715
break;
27162716
}
2717+
} else if (uc->arch == UC_ARCH_AVR) {
2718+
if (!avr_cpu_model_valid(model)) {
2719+
err = UC_ERR_ARG;
2720+
break;
2721+
}
27172722
} else {
27182723
err = UC_ERR_ARG;
27192724
break;

0 commit comments

Comments
 (0)