Skip to content

Commit 52668c0

Browse files
committed
update avr
1 parent 7f77dce commit 52668c0

File tree

16 files changed

+1453
-2445
lines changed

16 files changed

+1453
-2445
lines changed

include/uc_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
(UC_MODE_ARM | UC_MODE_THUMB | UC_MODE_LITTLE_ENDIAN | UC_MODE_MCLASS | \
2323
UC_MODE_ARM926 | UC_MODE_ARM946 | UC_MODE_ARM1176 | UC_MODE_BIG_ENDIAN | \
2424
UC_MODE_ARMBE8)
25+
#define UC_MODE_AVR_MASK (UC_MODE_LITTLE_ENDIAN)
2526
#define UC_MODE_MIPS_MASK \
2627
(UC_MODE_MIPS32 | UC_MODE_MIPS64 | UC_MODE_LITTLE_ENDIAN | \
2728
UC_MODE_BIG_ENDIAN)
@@ -35,7 +36,6 @@
3536
(UC_MODE_RISCV32 | UC_MODE_RISCV64 | UC_MODE_LITTLE_ENDIAN)
3637
#define UC_MODE_S390X_MASK (UC_MODE_BIG_ENDIAN)
3738
#define UC_MODE_TRICORE_MASK (UC_MODE_LITTLE_ENDIAN)
38-
#define UC_MODE_AVR_MASK (UC_MODE_LITTLE_ENDIAN)
3939

4040
#define ARR_SIZE(a) (sizeof(a) / sizeof(a[0]))
4141

include/unicorn/avr.h

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,26 @@ extern "C" {
1717
#pragma warning(disable : 4201)
1818
#endif
1919

20-
//> AVR architectures
21-
typedef enum uc_avr_arch {
22-
UC_AVR_ARCH_AVR1 = 10,
23-
UC_AVR_ARCH_AVR2 = 20,
24-
UC_AVR_ARCH_AVR25 = 25,
25-
UC_AVR_ARCH_AVR3 = 30,
26-
UC_AVR_ARCH_AVR4 = 40,
27-
UC_AVR_ARCH_AVR5 = 50,
28-
UC_AVR_ARCH_AVR51 = 51,
29-
UC_AVR_ARCH_AVR6 = 60,
30-
} uc_avr_arch;
31-
32-
#define UC_CPU_AVR_ARCH 1000
33-
3420
//> AVR CPU
3521
typedef enum uc_cpu_avr {
36-
// Enhanced Core with 16K up to 64K of program memory ("AVR5")
37-
UC_CPU_AVR_ATMEGA16 = UC_AVR_ARCH_AVR5*UC_CPU_AVR_ARCH + 16,
38-
UC_CPU_AVR_ATMEGA32 = UC_AVR_ARCH_AVR5*UC_CPU_AVR_ARCH + 32,
39-
UC_CPU_AVR_ATMEGA64 = UC_AVR_ARCH_AVR5*UC_CPU_AVR_ARCH + 64,
40-
41-
// Enhanced Core with 128K of program memory ("AVR5.1")
42-
UC_CPU_AVR_ATMEGA128 = UC_AVR_ARCH_AVR51*UC_CPU_AVR_ARCH + 128,
43-
UC_CPU_AVR_ATMEGA128RFR2,
44-
UC_CPU_AVR_ATMEGA1280,
45-
46-
// Enhanced Core with 128K+ of program memory, i.e. 3-byte PC ("AVR6")
47-
UC_CPU_AVR_ATMEGA256 = UC_AVR_ARCH_AVR6*UC_CPU_AVR_ARCH + 256,
48-
UC_CPU_AVR_ATMEGA256RFR2,
49-
UC_CPU_AVR_ATMEGA2560,
50-
} uc_cpu_avr;
22+
// Enhanced Core with 16K up to 64K of program memory (AVR5)
23+
UC_CPU_AVR_5,
24+
25+
// Enhanced Core with 128K of program memory (AVR5.1)
26+
UC_CPU_AVR_51,
5127

52-
//> AVR memory
53-
typedef enum uc_avr_mem {
54-
// Flash program memory (code)
55-
UC_AVR_MEM_FLASH = 0x08000000,
56-
} uc_avr_mem;
28+
// Enhanced Core with 128K+ of program memory, i.e. 3-byte PC (AVR6)
29+
UC_CPU_AVR_6,
30+
31+
UC_CPU_AVR_ENDING,
32+
} uc_cpu_avr;
5733

5834
//> AVR registers
5935
typedef enum uc_avr_reg {
6036
UC_AVR_REG_INVALID = 0,
6137

6238
// General purpose registers (GPR)
63-
UC_AVR_REG_R0 = 1,
39+
UC_AVR_REG_R0,
6440
UC_AVR_REG_R1,
6541
UC_AVR_REG_R2,
6642
UC_AVR_REG_R3,
@@ -96,7 +72,7 @@ typedef enum uc_avr_reg {
9672
UC_AVR_REG_PC,
9773
UC_AVR_REG_SP,
9874

99-
UC_AVR_REG_RAMPD = UC_AVR_REG_PC + 16 + 8,
75+
UC_AVR_REG_RAMPD,
10076
UC_AVR_REG_RAMPX,
10177
UC_AVR_REG_RAMPY,
10278
UC_AVR_REG_RAMPZ,
@@ -106,7 +82,7 @@ typedef enum uc_avr_reg {
10682
UC_AVR_REG_SREG,
10783

10884
//> 16-bit coalesced registers
109-
UC_AVR_REG_R0W = UC_AVR_REG_PC + 32,
85+
UC_AVR_REG_R0W,
11086
UC_AVR_REG_R1W,
11187
UC_AVR_REG_R2W,
11288
UC_AVR_REG_R3W,
@@ -139,7 +115,7 @@ typedef enum uc_avr_reg {
139115
UC_AVR_REG_R30W,
140116

141117
//> 32-bit coalesced registers
142-
UC_AVR_REG_R0D = UC_AVR_REG_PC + 64,
118+
UC_AVR_REG_R0D,
143119
UC_AVR_REG_R1D,
144120
UC_AVR_REG_R2D,
145121
UC_AVR_REG_R3D,

qemu/include/tcg/tcg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,11 @@ struct TCGContext {
834834
TCGv cpu_rampX;
835835
TCGv cpu_rampY;
836836
TCGv cpu_rampZ;
837+
TCGv cpu_r[32];
837838
TCGv cpu_eind;
838839
TCGv cpu_sp;
839840
TCGv cpu_skip;
841+
char cpu_avr_reg_names[32][8];
840842
};
841843

842844
static inline size_t temp_idx(TCGContext *tcg_ctx, TCGTemp *ts)

qemu/target/avr/cpu-qom.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,27 @@
2323

2424
#include "hw/core/cpu.h"
2525

26-
typedef void Object;
27-
typedef void ObjectClass;
28-
29-
typedef void DeviceState;
30-
typedef void (*DeviceRealize)(DeviceState *ds);
31-
typedef void (*DeviceReset)(DeviceState *ds);
32-
3326
#define TYPE_AVR_CPU "avr-cpu"
3427

3528
#define AVR_CPU(obj) ((AVRCPU *)obj)
3629
#define AVR_CPU_CLASS(klass) ((AVRCPUClass *)klass)
3730
#define AVR_CPU_GET_CLASS(obj) (&((AVRCPU *)obj)->cc)
3831

32+
typedef struct AVRCPUInfo {
33+
const char *name;
34+
void (*initfn)(CPUState *obj);
35+
} AVRCPUInfo;
36+
3937
/**
40-
* AVRCPUClass:
41-
* @parent_realize: The parent class' realize handler.
42-
* @parent_reset: The parent class' reset handler.
43-
* @vr: Version Register value.
44-
*
45-
* A AVR CPU model.
38+
* AVRCPUClass: An AVR CPU model.
4639
*/
4740
typedef struct AVRCPUClass {
4841
/*< private >*/
4942
CPUClass parent_class;
5043
/*< public >*/
51-
DeviceRealize parent_realize;
52-
DeviceReset parent_reset;
44+
45+
const AVRCPUInfo *info;
46+
void (*parent_reset)(CPUState *cpu);
5347
} AVRCPUClass;
5448

5549

0 commit comments

Comments
 (0)