8bit AVR cores
v14 cover 8bit AVR cores
This series of patches adds 8bit AVR cores to QEMU.
All instruction, except BREAK/DES/SPM/SPMX, are implemented. Not fully tested yet. However I was able to execute simple code with functions. e.g fibonacci calculation. This series of patches include a non real, sample board.
No fuses support yet. PC is set to 0 at reset.
the patches include the following
1. just a basic 8bit AVR CPU, without instruction decoding or translation
2. CPU features which allow define the following 8bit AVR cores
avr1
avr2 avr25
avr3 avr31 avr35
avr4
avr5 avr51
avr6
xmega2 xmega4 xmega5 xmega6 xmega73. a definition of sample machine with SRAM, FLASH and CPU which allows to execute simple code
4. encoding for all AVR instructions
5. interrupt handling
6. helpers for IN, OUT, SLEEP, WBR & unsupported instructions
7. a decoder which given an opcode decides what istruction it is
8. translation of AVR instruction into TCG
9. all features together
changes since v3
1. rampD/X/Y/Z registers are encoded as 0x00ff0000 (instead of 0x000000ff) for faster address manipulaton
2. ffs changed to ctz32
3. duplicate code removed at avr_cpu_do_interrupt
4. using andc instead of not + and
5. fixing V flag calculation in varios instructions
6. freeing local variables in PUSH
7. tcg_const_local_i32 -> tcg_const_i32
8. using sextract32 instead of my implementation
9. fixing BLD instruction
10.xor(r) instead of 0xff - r at COM
11.fixing MULS/MULSU not to modify inputs' content
12.using SUB for NEG
13.fixing tcg_gen_qemu_ld/st call in XCH
changes since v4
1. target is now defined as big endian in order to optimize push_ret/pop_ret
2. all style warnings are fixed
3. adding cpu_set/get_sreg functions
4. simplifying gen_goto_tb as there is no real paging
5. env->pc -> env->pc_w
6. making flag dump more compact
7. more spacing
8. renaming CODE/DATA_INDEX -> MMU_CODE/DATA_IDX
9. removing avr_set_feature
10. SPL/SPH set bug fix
11. switching stb_phys to cpu_stb_data
12. cleaning up avr_decode
13. saving sreg, rampD/X/Y/Z, eind in HW format (savevm)
14. saving CPU features (savevm)
changes since v5
1. BLD bug fix
2. decoder generator is added
chages since v6
1. using cpu_get_sreg/cpu_set_sreg in avr_cpu_gdb_read_register/avr_cpu_gdb_write_register
2. configure the target as little endian because otherwise GDB does not work
3. fixing and testing gen_push_ret/gen_pop_ret
changes since v7
1. folding back v6
2. logging at helper_outb and helper_inb are done for non supported yet registers only
3. MAINTAINERS updated
changes since v8
1. removing hw/avr from hw/Makefile.obj as it should not be built for all
2. making linux compilable
3. testing on
a. Mac, Apple LLVM version 7.0.0
b. Ubuntu 12.04, gcc 4.9.2
c. Fedora 23, gcc 5.3.14. folding back some patches
5. translation bug fixes for ORI, CPI, XOR instructions
6. propper handling of cpu register writes though memory
changes since v9
1. removing forward declarations of static functions
2. disabling debug prints
3. switching to case range instead of if else if ...
4. LD/ST IN/OUT accessing CPU maintainder registers are not routed to any device
5. commenst about sample board and sample IO device added
6. sample board description is more descriptive now
7. memory_region_allocate_system_memory is used to create RAM
8. now there are helper_fullrd & helper_fullwr when LD/ST try to access registers
changes since v10
1. movig back fullwr & fullrd into the commit where outb and inb were introduced
2. changing tlb_fill function signature
3. adding empty line between functions
4. adding newline on the last line of the file
5. using tb->flags to generae full access ST/LD instructions
6. fixing SBRC bug
7. folding back 10th commit
8. whenever a new file is introduced it's added to Makefile.objs
changes since v11
1. updating to v2.7.0-rc
2. removing assignment to env->fullacc from gen_intermediate_code
changes since v12
1. fixing spacing
2. fixing get/put_segment functions
3. removing target-avr/machine.h file
4. VMSTATE_SINGLE_TEST -> VMSTATE_SINGLE
5. comment spelling
6. removing hw/avr/sample_io.c
7. char const* -> const char*
8. proper ram allocation
9. fixing breakpoint functionality.
10.env1 -> env
11.fixing avr_cpu_gdb_write_register & avr_cpu_gdb_read_register functions 12.any cpu is removed
12.feature bits are not saved into vm state
changes since v13
1. rebasing to v2.7.0-rc1
Michael Rolnik (9):
target-avr: AVR cores support is added.
target-avr: adding AVR CPU features/flavors
target-avr: adding a sample AVR board
target-avr: adding instructions encodings
target-avr: adding AVR interrupt handling
target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported
instructions
target-avr: adding instruction translation
target-avr: instruction decoder generator
target-avr: adding instruction decoder
MAINTAINERS | 6 + arch_init.c | 2 + configure | 5 + default-configs/avr-softmmu.mak | 21 + hw/avr/Makefile.objs | 21 + hw/avr/sample.c | 117 ++ include/disas/bfd.h | 6 + include/sysemu/arch_init.h | 1 + target-avr/Makefile.objs | 24 + target-avr/cpu-qom.h | 85 + target-avr/cpu.c | 605 +++++++ target-avr/cpu.h | 244 +++ target-avr/cpugen/CMakeLists.txt | 38 + target-avr/cpugen/README.md | 17 + target-avr/cpugen/cpu/avr.yaml | 214 +++ target-avr/cpugen/src/.cpugen.cpp.swp | Bin 0 -> 24576 bytes target-avr/cpugen/src/CMakeLists.txt | 63 + target-avr/cpugen/src/cpugen.cpp | 458 +++++ target-avr/cpugen/src/utils.cpp | 27 + target-avr/cpugen/src/utils.h | 79 + target-avr/cpugen/xsl/decode.c.xsl | 103 ++ target-avr/cpugen/xsl/translate-inst.h.xsl | 118 ++ target-avr/cpugen/xsl/utils.xsl | 108 ++ target-avr/decode.c | 693 ++++++++ target-avr/gdbstub.c | 86 + target-avr/helper.c | 403 +++++ target-avr/helper.h | 29 + target-avr/machine.c | 116 ++ target-avr/translate-inst.c | 2625 ++++++++++++++++++++++++++++ target-avr/translate-inst.h | 805 +++++++++ target-avr/translate.c | 281 +++ target-avr/translate.h | 117 ++ 32 files changed, 7517 insertions(+) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c create mode 100644 target-avr/Makefile.objs create mode 100644 target-avr/cpu-qom.h create mode 100644 target-avr/cpu.c create mode 100644 target-avr/cpu.h create mode 100644 target-avr/cpugen/CMakeLists.txt create mode 100644 target-avr/cpugen/README.md create mode 100644 target-avr/cpugen/cpu/avr.yaml create mode 100644 target-avr/cpugen/src/.cpugen.cpp.swp create mode 100644 target-avr/cpugen/src/CMakeLists.txt create mode 100644 target-avr/cpugen/src/cpugen.cpp create mode 100644 target-avr/cpugen/src/utils.cpp create mode 100644 target-avr/cpugen/src/utils.h create mode 100644 target-avr/cpugen/xsl/decode.c.xsl create mode 100644 target-avr/cpugen/xsl/translate-inst.h.xsl create mode 100644 target-avr/cpugen/xsl/utils.xsl create mode 100644 target-avr/decode.c create mode 100644 target-avr/gdbstub.c create mode 100644 target-avr/helper.c create mode 100644 target-avr/helper.h create mode 100644 target-avr/machine.c create mode 100644 target-avr/translate-inst.c create mode 100644 target-avr/translate-inst.h create mode 100644 target-avr/translate.c create mode 100644 target-avr/translate.h
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 2/9 target-avr: adding AVR CPU features/flavors
--- target-avr/cpu.c | 319 +++++++++++++++++++++++++++++++++++++++++++++++++-- target-avr/cpu.h | 52 ++++++++- target-avr/machine.c | 28 ++--- 3 files changed, 373 insertions(+), 26 deletions(-)
target-avr/cpu.c +309 -10
@@ -203,9 +203,300 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) dc->cannot_destroy_with_object_finalize_yet = true; } -static void avr_any_initfn (Object *obj) +static void avr_avr1_initfn (Object *obj) { -/* Set cpu feature flags */ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +} + +static void avr_avr2_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +} + +static void avr_avr25_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +} + +static void avr_avr3_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +} + +static void avr_avr31_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +} + +static void avr_avr35_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +} + +static void avr_avr4_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +} + +static void avr_avr5_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +} + +static void avr_avr51_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_ELPMX ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +} + +static void avr_avr6_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_3_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_EIJMP_EICALL ); +avr_set_feature (env,AVR_FEATURE_ELPMX ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +} + +static void avr_xmega2_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +avr_set_feature (env,AVR_FEATURE_RMW ); +} + +static void avr_xmega4_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_ELPMX ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +avr_set_feature (env,AVR_FEATURE_RMW ); +} + +static void avr_xmega5_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_2_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPD ); +avr_set_feature (env,AVR_FEATURE_RAMPX ); +avr_set_feature (env,AVR_FEATURE_RAMPY ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_ELPMX ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +avr_set_feature (env,AVR_FEATURE_RMW ); +} + +static void avr_xmega6_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_3_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_EIJMP_EICALL ); +avr_set_feature (env,AVR_FEATURE_ELPMX ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +avr_set_feature (env,AVR_FEATURE_RMW ); +} + +static void avr_xmega7_initfn (Object *obj) +{ +AVRCPU *cpu =AVR_CPU (obj); +CPUAVRState *env = &cpu->env; + +avr_set_feature (env,AVR_FEATURE_LPM ); +avr_set_feature (env,AVR_FEATURE_IJMP_ICALL ); +avr_set_feature (env,AVR_FEATURE_ADIW_SBIW ); +avr_set_feature (env,AVR_FEATURE_SRAM ); +avr_set_feature (env,AVR_FEATURE_BREAK ); + +avr_set_feature (env,AVR_FEATURE_3_BYTE_PC ); +avr_set_feature (env,AVR_FEATURE_2_BYTE_SP ); +avr_set_feature (env,AVR_FEATURE_RAMPD ); +avr_set_feature (env,AVR_FEATURE_RAMPX ); +avr_set_feature (env,AVR_FEATURE_RAMPY ); +avr_set_feature (env,AVR_FEATURE_RAMPZ ); +avr_set_feature (env,AVR_FEATURE_EIJMP_EICALL ); +avr_set_feature (env,AVR_FEATURE_ELPMX ); +avr_set_feature (env,AVR_FEATURE_ELPM ); +avr_set_feature (env,AVR_FEATURE_JMP_CALL ); +avr_set_feature (env,AVR_FEATURE_LPMX ); +avr_set_feature (env,AVR_FEATURE_MOVW ); +avr_set_feature (env,AVR_FEATURE_MUL ); +avr_set_feature (env,AVR_FEATURE_RMW ); } typedef struct AVRCPUInfo {
@@ -214,7 +505,21 @@ typedef struct AVRCPUInfo { } AVRCPUInfo;static const AVRCPUInfo avr_cpus[] = { - { .name ="any" , .initfn = avr_any_initfn }, + {.name ="avr1" , .initfn = avr_avr1_initfn}, + {.name ="avr2" , .initfn = avr_avr2_initfn}, + {.name ="avr25" , .initfn = avr_avr25_initfn}, + {.name ="avr3" , .initfn = avr_avr3_initfn}, + {.name ="avr31" , .initfn = avr_avr31_initfn}, + {.name ="avr35" , .initfn = avr_avr35_initfn}, + {.name ="avr4" , .initfn = avr_avr4_initfn}, + {.name ="avr5" , .initfn = avr_avr5_initfn}, + {.name ="avr51" , .initfn = avr_avr51_initfn}, + {.name ="avr6" , .initfn = avr_avr6_initfn}, + {.name ="xmega2" , .initfn = avr_xmega2_initfn}, + {.name ="xmega4" , .initfn = avr_xmega4_initfn}, + {.name ="xmega5" , .initfn = avr_xmega5_initfn}, + {.name ="xmega6" , .initfn = avr_xmega6_initfn}, + {.name ="xmega7" , .initfn = avr_xmega7_initfn}, };static gint avr_cpu_list_compare (gconstpointer a,gconstpointer b)
@@ -226,13 +531,7 @@ static gint avr_cpu_list_compare(gconstpointer a, gconstpointer b) name_a =object_class_get_name (class_a); name_b =object_class_get_name (class_b); -if (strcmp (name_a,"any-" TYPE_AVR_CPU ) ==0 ) { -return 1 ; - }else if (strcmp (name_b,"any-" TYPE_AVR_CPU ) ==0 ) { -return -1 ; - }else { -return strcmp (name_a, name_b); - } +return strcmp (name_a, name_b); }static void avr_cpu_list_entry (gpointer data,gpointer user_data)
target-avr/cpu.h +50 -2
68 lines not on this page · raw message
target-avr/machine.c +14 -14
@@ -44,8 +44,8 @@ static void put_sreg(QEMUFile *f, void *opaque, size_t size)static const VMStateInfo vms_sreg = { .name ="sreg" , - .get = get_sreg, - .put = put_sreg, + .get = get_sreg, + .put = put_sreg, };static int get_segment (QEMUFile *f,void *opaque,size_t size)
@@ -68,33 +68,33 @@ static void put_segment(QEMUFile *f, void *opaque, size_t size)static const VMStateInfo vms_rampD = { .name ="rampD" , - .get = get_segment, - .put = put_segment, + .get = get_segment, + .put = put_segment, };static const VMStateInfo vms_rampX = { .name ="rampX" , - .get = get_segment, - .put = put_segment, + .get = get_segment, + .put = put_segment, };static const VMStateInfo vms_rampY = { .name ="rampY" , - .get = get_segment, - .put = put_segment, + .get = get_segment, + .put = put_segment, };static const VMStateInfo vms_rampZ = { .name ="rampZ" , - .get = get_segment, - .put = put_segment, + .get = get_segment, + .put = put_segment, };static const VMStateInfo vms_eind = { .name ="eind" , - .get = get_segment, - .put = put_segment, + .get = get_segment, + .put = put_segment, };const VMStateDescription vms_avr_cpu = { - .name ="cpu" , - .version_id =0 , + .name ="cpu" , + .version_id =0 , .minimum_version_id =0 , .fields = (VMStateField []) {VMSTATE_UINT32 (env.pc_w,AVRCPU ),
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 3/9 target-avr: adding a sample AVR board
In reply to Michael Rolnik--- MAINTAINERS | 6 +++ hw/avr/Makefile.objs | 21 +++++++++ hw/avr/sample.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c
MAINTAINERS +6 -0
@@ -110,6 +110,12 @@ F: disas/arm.c F: disas/arm-a64.cc F: disas/libvixl/ +AVR +M: Michael Rolnik <[email protected]> +S: Maintained +F: target-avr/ +F: hw/avr/ + CRIS M: Edgar E. Iglesias <[email protected]> S: Maintained
hw/avr/Makefile.objs new file +21 -0
@@ -0,0 +1,21 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2016 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +obj-y += sample.o
hw/avr/sample.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 1/9 target-avr: AVR cores support is added.
In reply to Michael Rolnik 1. basic CPU structure
2. registers
3. no instructions
4. saving sreg, rampD, rampX, rampY, rampD, eind in HW representation
--- arch_init.c | 2 + configure | 5 + default-configs/avr-softmmu.mak | 21 +++ include/disas/bfd.h | 6 + include/sysemu/arch_init.h | 1 + target-avr/Makefile.objs | 23 +++ target-avr/cpu-qom.h | 85 +++++++++++ target-avr/cpu.c | 306 ++++++++++++++++++++++++++++++++++++++++ target-avr/cpu.h | 185 ++++++++++++++++++++++++ target-avr/gdbstub.c | 86 +++++++++++ target-avr/helper.c | 88 ++++++++++++ target-avr/helper.h | 22 +++ target-avr/machine.c | 116 +++++++++++++++ target-avr/translate.c | 282 ++++++++++++++++++++++++++++++++++++ target-avr/translate.h | 116 +++++++++++++++ 15 files changed, 1344 insertions(+) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 target-avr/Makefile.objs create mode 100644 target-avr/cpu-qom.h create mode 100644 target-avr/cpu.c create mode 100644 target-avr/cpu.h create mode 100644 target-avr/gdbstub.c create mode 100644 target-avr/helper.c create mode 100644 target-avr/helper.h create mode 100644 target-avr/machine.c create mode 100644 target-avr/translate.c create mode 100644 target-avr/translate.h
arch_init.c +2 -0
@@ -80,6 +80,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_UNICORE32#elif defined(TARGET_TRICORE )#define QEMU_ARCH QEMU_ARCH_TRICORE +#elif defined(TARGET_AVR ) +#define QEMU_ARCH QEMU_ARCH_AVR#endif const uint32_t arch_type =QEMU_ARCH ;
configure +5 -0
@@ -5641,6 +5641,8 @@ case "$target_name" in x86_64) TARGET_BASE_ARCH=i386 ;; + avr) + ;; alpha) ;; arm|armeb)
@@ -5837,6 +5839,9 @@ disas_config() { for i in $ARCH $TARGET_BASE_ARCH ; do case "$i" in + avr) + disas_config "AVR" + ;; alpha) disas_config "ALPHA" ;;
default-configs/avr-softmmu.mak new file +21 -0
@@ -0,0 +1,21 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2016 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +# Default configuration for avr-softmmu
include/disas/bfd.h +6 -0
@@ -213,6 +213,12 @@ enum bfd_architecture#define bfd_mach_m32r 0/* backwards compatibility */ bfd_arch_mn10200, /* Matsushita MN10200 */ bfd_arch_mn10300, /* Matsushita MN10300 */ + bfd_arch_avr, /* Atmel AVR microcontrollers. */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 bfd_arch_cris, /* Axis CRIS */#define bfd_mach_cris_v0_v10 255#define bfd_mach_cris_v32 32
include/sysemu/arch_init.h +1 -0
@@ -23,6 +23,7 @@ enum {QEMU_ARCH_UNICORE32 = (1 <<14 ),QEMU_ARCH_MOXIE = (1 <<15 ),QEMU_ARCH_TRICORE = (1 <<16 ), + QEMU_ARCH_AVR = (1 << 17), };extern const uint32_t arch_type;
target-avr/Makefile.objs new file +23 -0
@@ -0,0 +1,23 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2016 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +obj-y += translate.o cpu.o helper.o +obj-y += gdbstub.o +obj-$(CONFIG_SOFTMMU) += machine.o
target-avr/cpu-qom.h new file +85 -0
85 lines not on this page · raw message
target-avr/cpu.c new file +306 -0
306 lines not on this page · raw message
target-avr/cpu.h new file +185 -0
185 lines not on this page · raw message
target-avr/gdbstub.c new file +86 -0
86 lines not on this page · raw message
target-avr/helper.c new file +88 -0
88 lines not on this page · raw message
target-avr/helper.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* QEMU AVR CPU +* +* Copyright (c) 2016 Michael Rolnik +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see +* <http://www.gnu.org/licenses/lgpl-2.1.html> +*/ + +DEF_HELPER_1 (debug, void, env) +
target-avr/machine.c new file +116 -0
116 lines not on this page · raw message
target-avr/translate.c new file +282 -0
282 lines not on this page · raw message
target-avr/translate.h new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 5/9 target-avr: adding AVR interrupt handling
In reply to Michael Rolnik--- target-avr/helper.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-)
target-avr/helper.c +58 -1
@@ -31,11 +31,68 @@bool avr_cpu_exec_interrupt (CPUState *cs,int interrupt_request) { -return false; +CPUClass *cc =CPU_GET_CLASS (cs); +AVRCPU *cpu =AVR_CPU (cs); +CPUAVRState *env = &cpu->env; + +bool ret = false; + +if (interrupt_request &CPU_INTERRUPT_RESET ) { +if (cpu_interrupts_enabled (env)) { + cs->exception_index =EXCP_RESET ; + cc->do_interrupt (cs); + + cs->interrupt_request &= ~CPU_INTERRUPT_RESET ; + + ret = true; + } + } +if (interrupt_request &CPU_INTERRUPT_HARD ) { +if (cpu_interrupts_enabled (env) && env->intsrc !=0 ) { +int index =ctz32 (env->intsrc); + cs->exception_index =EXCP_INT (index); + cc->do_interrupt (cs); + + env->intsrc &= env->intsrc -1 ;/* clear the interrupt */ + cs->interrupt_request &= ~CPU_INTERRUPT_HARD ; + + ret = true; + } + } +return ret; }void avr_cpu_do_interrupt (CPUState *cs) { +AVRCPU *cpu =AVR_CPU (cs); +CPUAVRState *env = &cpu->env; + +uint32_t ret = env->pc_w; +int vector =0 ; +int size =avr_feature (env,AVR_FEATURE_JMP_CALL ) ?2 :1 ; +int base =0 ;/* TODO: where to get it */ + +if (cs->exception_index ==EXCP_RESET ) { + vector =0 ; + }else if (env->intsrc !=0 ) { + vector =ctz32 (env->intsrc) +1 ; + } + +if (avr_feature (env,AVR_FEATURE_3_BYTE_PC )) { +stb_phys (cs->as, env->sp--, (ret &0x0000ff )); +stb_phys (cs->as, env->sp--, (ret &0x00ff00 ) >>8 ); +stb_phys (cs->as, env->sp--, (ret &0xff0000 ) >>16 ); + }else if (avr_feature (env,AVR_FEATURE_2_BYTE_PC )) { +stb_phys (cs->as, env->sp--, (ret &0x0000ff )); +stb_phys (cs->as, env->sp--, (ret &0x00ff00 ) >>8 ); + }else { +stb_phys (cs->as, env->sp--, (ret &0x0000ff )); + } + + env->pc_w = base + vector * size; + env->sregI =0 ;/* clear Global Interrupt Flag */ + + cs->exception_index =-1 ; } int avr_cpu_memory_rw_debug(CPUState *cs, vaddr addr, uint8_t *buf,
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 4/9 target-avr: adding instructions encodings
In reply to Michael Rolnik--- target-avr/translate-inst.h | 805 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 805 insertions(+) create mode 100644 target-avr/translate-inst.h
target-avr/translate-inst.h new file +805 -0
@@ -0,0 +1,805 @@ +/* +* QEMU AVR CPU +* +* Copyright (c) 2016 Michael Rolnik +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see +* <http://www.gnu.org/licenses/lgpl-2.1.html> +*/ + +#ifndef AVR_TRANSLATE_INST_H_ +#define AVR_TRANSLATE_INST_H_ + +typedef struct DisasContext DisasContext ; + +int avr_translate_NOP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_MOVW (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t MOVW_Rr (uint32_t opcode) +{ +return extract32 (opcode,0 ,4 ); +} + +static inline uint32_t MOVW_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +int avr_translate_MULS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t MULS_Rr (uint32_t opcode) +{ +return extract32 (opcode,0 ,4 ); +} + +static inline uint32_t MULS_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +int avr_translate_MULSU (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t MULSU_Rr (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t MULSU_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,3 ); +} + +int avr_translate_FMUL (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t FMUL_Rr (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t FMUL_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,3 ); +} + +int avr_translate_FMULS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t FMULS_Rr (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t FMULS_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,3 ); +} + +int avr_translate_FMULSU (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t FMULSU_Rr (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t FMULSU_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,3 ); +} + +int avr_translate_CPC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t CPC_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t CPC_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_SBC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBC_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t SBC_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_ADD (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ADD_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t ADD_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_AND (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t AND_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t AND_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_EOR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t EOR_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t EOR_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_OR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t OR_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t OR_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_MOV (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t MOV_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t MOV_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_CPSE (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t CPSE_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t CPSE_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_CP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t CP_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t CP_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_SUB (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SUB_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t SUB_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_ADC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ADC_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t ADC_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_CPI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t CPI_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +static inline uint32_t CPI_Imm (uint32_t opcode) +{ +return (extract32 (opcode,8 ,4 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_SBCI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBCI_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +static inline uint32_t SBCI_Imm (uint32_t opcode) +{ +return (extract32 (opcode,8 ,4 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_ORI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ORI_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +static inline uint32_t ORI_Imm (uint32_t opcode) +{ +return (extract32 (opcode,8 ,4 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_SUBI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SUBI_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +static inline uint32_t SUBI_Imm (uint32_t opcode) +{ +return (extract32 (opcode,8 ,4 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_ANDI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ANDI_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +static inline uint32_t ANDI_Imm (uint32_t opcode) +{ +return (extract32 (opcode,8 ,4 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_LDDZ (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDDZ_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t LDDZ_Imm (uint32_t opcode) +{ +return (extract32 (opcode,13 ,1 ) <<5 ) | + (extract32 (opcode,10 ,2 ) <<3 ) | + (extract32 (opcode,0 ,3 )); +} + +int avr_translate_LDDY (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDDY_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t LDDY_Imm (uint32_t opcode) +{ +return (extract32 (opcode,13 ,1 ) <<5 ) | + (extract32 (opcode,10 ,2 ) <<3 ) | + (extract32 (opcode,0 ,3 )); +} + +int avr_translate_STDZ (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STDZ_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t STDZ_Imm (uint32_t opcode) +{ +return (extract32 (opcode,13 ,1 ) <<5 ) | + (extract32 (opcode,10 ,2 ) <<3 ) | + (extract32 (opcode,0 ,3 )); +} + +int avr_translate_STDY (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STDY_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t STDY_Imm (uint32_t opcode) +{ +return (extract32 (opcode,13 ,1 ) <<5 ) | + (extract32 (opcode,10 ,2 ) <<3 ) | + (extract32 (opcode,0 ,3 )); +} + +int avr_translate_LDS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDS_Imm (uint32_t opcode) +{ +return extract32 (opcode,0 ,16 ); +} + +static inline uint32_t LDS_Rd (uint32_t opcode) +{ +return extract32 (opcode,20 ,5 ); +} + +int avr_translate_LDZ2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDZ2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LDZ3 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDZ3_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LPM2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LPM2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LPMX (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LPMX_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_ELPM2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ELPM2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_ELPMX (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ELPMX_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LDY2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDY2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LDY3 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDY3_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LDX1 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDX1_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LDX2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDX2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LDX3 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDX3_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_POP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t POP_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STS_Imm (uint32_t opcode) +{ +return extract32 (opcode,0 ,16 ); +} + +static inline uint32_t STS_Rd (uint32_t opcode) +{ +return extract32 (opcode,20 ,5 ); +} + +int avr_translate_STZ2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STZ2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STZ3 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STZ3_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_XCH (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t XCH_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LAS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LAS_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LAC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LAC_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LAT (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LAT_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STY2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STY2_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STY3 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STY3_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STX1 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STX1_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STX2 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STX2_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_STX3 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t STX3_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_PUSH (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t PUSH_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_COM (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t COM_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_NEG (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t NEG_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_SWAP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SWAP_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_INC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t INC_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_ASR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ASR_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_LSR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LSR_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_ROR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ROR_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_BSET (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t BSET_Bit (uint32_t opcode) +{ +return extract32 (opcode,4 ,3 ); +} + +int avr_translate_IJMP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_EIJMP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_BCLR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t BCLR_Bit (uint32_t opcode) +{ +return extract32 (opcode,4 ,3 ); +} + +int avr_translate_RET (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_RETI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_ICALL (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_EICALL (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_SLEEP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_BREAK (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_WDR (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_LPM1 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_ELPM1 (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_SPM (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_SPMX (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); + +int avr_translate_DEC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t DEC_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_DES (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t DES_Imm (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +int avr_translate_JMP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t JMP_Imm (uint32_t opcode) +{ +return (extract32 (opcode,20 ,5 ) <<17 ) | + (extract32 (opcode,0 ,17 )); +} + +int avr_translate_CALL (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t CALL_Imm (uint32_t opcode) +{ +return (extract32 (opcode,20 ,5 ) <<17 ) | + (extract32 (opcode,0 ,17 )); +} + +int avr_translate_ADIW (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t ADIW_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,2 ); +} + +static inline uint32_t ADIW_Imm (uint32_t opcode) +{ +return (extract32 (opcode,6 ,2 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_SBIW (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBIW_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,2 ); +} + +static inline uint32_t SBIW_Imm (uint32_t opcode) +{ +return (extract32 (opcode,6 ,2 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_CBI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t CBI_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t CBI_Imm (uint32_t opcode) +{ +return extract32 (opcode,3 ,5 ); +} + +int avr_translate_SBIC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBIC_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t SBIC_Imm (uint32_t opcode) +{ +return extract32 (opcode,3 ,5 ); +} + +int avr_translate_SBI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBI_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t SBI_Imm (uint32_t opcode) +{ +return extract32 (opcode,3 ,5 ); +} + +int avr_translate_SBIS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBIS_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t SBIS_Imm (uint32_t opcode) +{ +return extract32 (opcode,3 ,5 ); +} + +int avr_translate_MUL (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t MUL_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t MUL_Rr (uint32_t opcode) +{ +return (extract32 (opcode,9 ,1 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_IN (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t IN_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t IN_Imm (uint32_t opcode) +{ +return (extract32 (opcode,9 ,2 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_OUT (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t OUT_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +static inline uint32_t OUT_Imm (uint32_t opcode) +{ +return (extract32 (opcode,9 ,2 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_RJMP (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t RJMP_Imm (uint32_t opcode) +{ +return extract32 (opcode,0 ,12 ); +} + +int avr_translate_LDI (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t LDI_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,4 ); +} + +static inline uint32_t LDI_Imm (uint32_t opcode) +{ +return (extract32 (opcode,8 ,4 ) <<4 ) | + (extract32 (opcode,0 ,4 )); +} + +int avr_translate_RCALL (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t RCALL_Imm (uint32_t opcode) +{ +return extract32 (opcode,0 ,12 ); +} + +int avr_translate_BRBS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t BRBS_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t BRBS_Imm (uint32_t opcode) +{ +return extract32 (opcode,3 ,7 ); +} + +int avr_translate_BRBC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t BRBC_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t BRBC_Imm (uint32_t opcode) +{ +return extract32 (opcode,3 ,7 ); +} + +int avr_translate_BLD (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t BLD_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t BLD_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_BST (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t BST_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t BST_Rd (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_SBRC (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBRC_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t SBRC_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +int avr_translate_SBRS (CPUAVRState *env,DisasContext * ctx,uint32_t opcode); +static inline uint32_t SBRS_Bit (uint32_t opcode) +{ +return extract32 (opcode,0 ,3 ); +} + +static inline uint32_t SBRS_Rr (uint32_t opcode) +{ +return extract32 (opcode,4 ,5 ); +} + +#endif +
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 6/9 target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported instructions
In reply to Michael Rolnik--- target-avr/cpu.h | 13 ++- target-avr/helper.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++--- target-avr/helper.h | 8 +- target-avr/translate.c | 9 ++ 4 files changed, 300 insertions(+), 18 deletions(-)
target-avr/cpu.h +12 -1
@@ -146,6 +146,7 @@ struct CPUAVRState {uint32_t sp;/* 16 bits */ uint64_t intsrc;/* interrupt sources */ +bool fullacc;/* CPU/MEM if true MEM only otherwise */ uint32_t features;
@@ -188,12 +189,22 @@ int avr_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,int avr_cpu_memory_rw_debug (CPUState *cs,vaddr address,uint8_t *buf,int len,bool is_write); +enum { +TB_FLAGS_FULL_ACCESS =1 , +};static inline void cpu_get_tb_cpu_state (CPUAVRState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *pflags) { +uint32_t flags =0 ; + *pc = env->pc_w *2 ; *cs_base =0 ; - *pflags =0 ; + +if (env->fullacc) { + flags |=TB_FLAGS_FULL_ACCESS ; + } + + *pflags = flags; }static inline int cpu_interrupts_enabled (CPUAVRState *env)
target-avr/helper.c +272 -16
348 lines not on this page · raw message
target-avr/helper.h +7 -1
@@ -18,5 +18,11 @@* <http://www.gnu.org/licenses/lgpl-2.1.html> */ +DEF_HELPER_1(wdr, void, env) DEF_HELPER_1(debug, void, env) - +DEF_HELPER_1(sleep, void, env) +DEF_HELPER_1(unsupported, void, env) +DEF_HELPER_3(outb, void, env, i32, i32) +DEF_HELPER_2(inb, tl, env, i32) +DEF_HELPER_3(fullwr, void, env, i32, i32) +DEF_HELPER_2 (fullrd, tl, env, i32)
target-avr/translate.c +9 -0
@@ -151,6 +151,14 @@ void gen_intermediate_code(CPUAVRState *env, struct TranslationBlock *tb)if (max_insns >TCG_MAX_INSNS ) { max_insns =TCG_MAX_INSNS ; } +if (tb->flags &TB_FLAGS_FULL_ACCESS ) { +/* +this flag is set by ST/LD instruction +we will regenerate ONLY it with mem/cpu memory access +insttead of mem access +*/ + max_insns =1 ; + }gen_tb_start (tb);
@@ -221,6 +229,7 @@ void gen_intermediate_code(CPUAVRState *env, struct TranslationBlock *tb) } done_generating: + env->fullacc = false;gen_tb_end (tb, num_insns); tb->size = (npc - pc_start) *2 ;
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 8/9 target-avr: instruction decoder generator
In reply to Michael Rolnik--- target-avr/cpugen/CMakeLists.txt | 38 +++ target-avr/cpugen/README.md | 17 ++ target-avr/cpugen/cpu/avr.yaml | 214 ++++++++++++++ target-avr/cpugen/src/CMakeLists.txt | 63 ++++ target-avr/cpugen/src/cpugen.cpp | 458 +++++++++++++++++++++++++++++ target-avr/cpugen/src/utils.cpp | 27 ++ target-avr/cpugen/src/utils.h | 79 +++++ target-avr/cpugen/xsl/decode.c.xsl | 103 +++++++ target-avr/cpugen/xsl/translate-inst.h.xsl | 118 ++++++++ target-avr/cpugen/xsl/utils.xsl | 108 +++++++ 10 files changed, 1225 insertions(+) create mode 100644 target-avr/cpugen/CMakeLists.txt create mode 100644 target-avr/cpugen/README.md create mode 100644 target-avr/cpugen/cpu/avr.yaml create mode 100644 target-avr/cpugen/src/CMakeLists.txt create mode 100644 target-avr/cpugen/src/cpugen.cpp create mode 100644 target-avr/cpugen/src/utils.cpp create mode 100644 target-avr/cpugen/src/utils.h create mode 100644 target-avr/cpugen/xsl/decode.c.xsl create mode 100644 target-avr/cpugen/xsl/translate-inst.h.xsl create mode 100644 target-avr/cpugen/xsl/utils.xsl
target-avr/cpugen/CMakeLists.txt new file +38 -0
@@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 2.8) + +project(cpugen) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb -g3") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + +set(Boost_USE_STATIC_LIBS ON) +find_package( + Boost 1.60.0 + REQUIRED + COMPONENTS + system + regex) +#set(BUILD_SHARED_LIBS OFF) +#set(BUILD_STATIC_LIBS ON) +add_subdirectory(tinyxml2) +add_subdirectory(yaml-cpp) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR}/../yaml-cpp/include + ${Boost_INCLUDE_DIRS} +) + +add_executable( + cpugen + src/cpugen.cpp + src/utils.cpp +) + +target_link_libraries( + cpugen + yaml-cpp + tinyxml2 + ${Boost_LIBRARIES} +)
target-avr/cpugen/README.md new file +17 -0
@@ -0,0 +1,17 @@ +# CPUGEN +## How to build +within ```cpugen``` directory do +``` +git clone https://github.com/leethomason/tinyxml2 +git clone https://github.com/jbeder/yaml-cpp +mkdir build +cd build +cmake .. +make +``` +## How to use +``` +cpugen ../cpu/avr.yaml +xsltproc ../xsl/decode.c.xsl output.xml > ../../decode.c +xsltproc ../xsl/translate-inst.h.xsl output.xml > ../../translate-inst.h +```
target-avr/cpugen/cpu/avr.yaml new file +214 -0
214 lines not on this page · raw message
target-avr/cpugen/src/CMakeLists.txt new file +63 -0
63 lines not on this page · raw message
target-avr/cpugen/src/cpugen.cpp new file +458 -0
458 lines not on this page · raw message
target-avr/cpugen/src/utils.cpp new file +27 -0
@@ -0,0 +1,27 @@ +/* + * CPUGEN + * + * Copyright (c) 2016 Michael Rolnik + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "utils.h" +#include <sstream> +
target-avr/cpugen/src/utils.h new file +79 -0
79 lines not on this page · raw message
target-avr/cpugen/xsl/decode.c.xsl new file +103 -0
103 lines not on this page · raw message
target-avr/cpugen/xsl/translate-inst.h.xsl new file +118 -0
118 lines not on this page · raw message
target-avr/cpugen/xsl/utils.xsl new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 7/9 target-avr: adding instruction translation
In reply to Michael Rolnik--- target-avr/Makefile.objs | 2 +- target-avr/translate-inst.c | 2622 +++++++++++++++++++++++++++++++++++++++++++ target-avr/translate.c | 1 - target-avr/translate.h | 1 + 4 files changed, 2624 insertions(+), 2 deletions(-) create mode 100644 target-avr/translate-inst.c
target-avr/Makefile.objs +1 -1
@@ -18,6 +18,6 @@ # <http://www.gnu.org/licenses/lgpl-2.1.html> # -obj-y += translate.o cpu.o helper.o +obj-y += translate.o cpu.o helper.o translate-inst.o obj-y += gdbstub.o obj-$(CONFIG_SOFTMMU) += machine.o
target-avr/translate-inst.c new file +2622 -0
2,622 lines not on this page · raw message
target-avr/translate.c +0 -1
@@ -229,7 +229,6 @@ void gen_intermediate_code(CPUAVRState *env, struct TranslationBlock *tb) } done_generating: - env->fullacc = false;gen_tb_end (tb, num_insns); tb->size = (npc - pc_start) *2 ;
target-avr/translate.h +1 -0
@@ -33,6 +33,7 @@#include "exec/helper-proto.h" #include "exec/helper-gen.h" #include "exec/log.h" +#include "translate-inst.h" extern TCGv_env cpu_env;
Signature · 1 line
2.4.9 (Apple Git-60)
PATCH v14 9/9 target-avr: adding instruction decoder
In reply to Michael Rolnik--- target-avr/Makefile.objs | 1 + target-avr/cpugen/src/.cpugen.cpp.swp | Bin 0 -> 24576 bytes target-avr/decode.c | 693 +++++++++++++++ target-avr/helper.c | 2 + target-avr/helper.h | 1 + target-avr/translate-inst.c | 1529 +++++++++++++++++---------------- target-avr/translate.c | 29 +- 7 files changed, 1473 insertions(+), 782 deletions(-) create mode 100644 target-avr/cpugen/src/.cpugen.cpp.swp create mode 100644 target-avr/decode.c
target-avr/Makefile.objs +1 -0
@@ -20,4 +20,5 @@ obj-y += translate.o cpu.o helper.o translate-inst.o obj-y += gdbstub.o +obj-y += decode.o obj-$(CONFIG_SOFTMMU) += machine.o
target-avr/cpugen/src/.cpugen.cpp.swp new file binary +0 -0
target-avr/decode.c new file +693 -0
693 lines not on this page · raw message
target-avr/helper.c +2 -0
@@ -153,6 +153,7 @@ void tlb_fill(CPUState *cs, target_ulong vaddr, MMUAccessType access_type,tlb_set_page_with_attrs (cs, vaddr, paddr, attrs, prot, mmu_idx, page_size); } +void helper_sleep (CPUAVRState *env) {CPUState *cs =CPU (avr_env_get_cpu (env));
@@ -160,6 +161,7 @@ void helper_sleep(CPUAVRState *env) cs->exception_index =EXCP_HLT ;cpu_loop_exit (cs); } +void helper_unsupported (CPUAVRState *env) {CPUState *cs =CPU (avr_env_get_cpu (env));
target-avr/helper.h +1 -0
@@ -26,3 +26,4 @@ DEF_HELPER_3(outb, void, env, i32, i32) DEF_HELPER_2(inb, tl, env, i32) DEF_HELPER_3(fullwr, void, env, i32, i32)DEF_HELPER_2 (fullrd, tl, env, i32) +
target-avr/translate-inst.c +766 -763
2,284 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.4.9 (Apple Git-60)
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH v14 1/9] target-avr: AVR cores support is added.
In reply to Michael RolnikQuoted 12 lines · Michael Rolnik
1. basic CPU structure
2. registers
3. no instructions
4. saving sreg, rampD, rampX, rampY, rampD, eind in HW representationSigned-off-by Michael Rolnik <[email protected]>configure +0
-0
configure case "$target_name" in · line 5645
Quoted 5 lines
configure +2
-0@@ -5641,6 +5641,8 @@ case "$target_name" in x86_64) TARGET_BASE_ARCH=i386 ;; + avr) + ;;
I asked you to move this in my review of v12, but you haven't.
configure disas_config() { · line 5844
Quoted 10 lines
configure +3
-0alpha) ;; arm|armeb)@@ -5837,6 +5839,9 @@ disas_config() { for i in $ARCH $TARGET_BASE_ARCH ; do case "$i" in + avr) + disas_config "AVR" + ;;
Ditto.
Quoted 16 lines
configure +12
-0alpha) disas_config "ALPHA" ;; +#ifndef QEMU_AVR_CPU_QOM_H +#define QEMU_AVR_CPU_QOM_H + +#include "qom/cpu.h" + +#define TYPE_AVR_CPU "avr" + +#define AVR_CPU_CLASS(klass) \ + OBJECT_CLASS_CHECK(AVRCPUClass, (klass), TYPE_AVR_CPU) +#define AVR_CPU(obj) \ + OBJECT_CHECK(AVRCPU, (obj), TYPE_AVR_CPU) +#define AVR_CPU_GET_CLASS(obj) \
configure disas_config() {
Quoted 10 lines
configure +10
-0+ OBJECT_GET_CLASS(AVRCPUClass, (obj), TYPE_AVR_CPU) + +/** +* AVRCPUClass: +* @parent_realize: The parent class' realize handler. +* @parent_reset: The parent class' reset handler. +* @vr: Version Register value. +* +* A AVR CPU model. + */
The spacing here is still wrong.
configure
Quoted 13 lines
configure +13
-0+typedef struct AVRCPUClass { + CPUClass parent_class; + + DeviceRealize parent_realize; + void (*parent_reset)(CPUState *cpu); +} AVRCPUClass; + +/** +* AVRCPU: +* @env: #CPUAVRState +* +* A AVR CPU. +*/
Ditto.
Quoted 7 lines
configure +7
-0+typedef struct AVRCPU { + /* < private > */ + CPUState parent_obj; + /* < public > */ + + CPUAVRState env; +} AVRCPU;
configure
Quoted 10 lines
configure +9
-0+static bool avr_cpu_has_work(CPUState *cs) +{ + AVRCPU *cpu = AVR_CPU(cs); + CPUAVRState *env = &cpu->env; + + return (cs->interrupt_request + & (CPU_INTERRUPT_HARD + | CPU_INTERRUPT_RESET)) + && cpu_interrupts_enabled(env);
I asked you to fix this spacing, but it's still all over the place.
If you could check that you've addressed all the comments from previous patch review rounds that would make things faster.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 2/9] target-avr: adding AVR CPU features/flavors
In reply to Michael RolnikQuoted 12 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>--- target-avr/cpu.c | 319 +++++++++++++++++++++++++++++++++++++++++++++++++-- target-avr/cpu.h | 52 ++++++++- target-avr/machine.c | 28 ++--- 3 files changed, 373 insertions(+), 26 deletions(-)target-avr/cpu.c +0
-0
target-avr/cpu.c static void avr_cpu_class_init(ObjectClass *oc, void *data) · line 206
Quoted 4 lines
target-avr/cpu.c +0
-1@@ -203,9 +203,300 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) dc->cannot_destroy_with_object_finalize_yet = true; } -static void avr_any_initfn (Object *obj)
Please don't add code in one patch and then remove it in the next.
target-avr/cpu.c static gint avr_cpu_list_compare(gconstpointer a, gconstpointer b) · line 535
Quoted 13 lines
target-avr/cpu.c +1
-7@@ -226,13 +531,7 @@ static gint avr_cpu_list_compare(gconstpointer a, gconstpointer b) name_a =object_class_get_name (class_a); name_b =object_class_get_name (class_b); -if (strcmp (name_a,"any-" TYPE_AVR_CPU ) ==0 ) { -return 1 ; - }else if (strcmp (name_b,"any-" TYPE_AVR_CPU ) ==0 ) { -return -1 ; - }else { -return strcmp (name_a, name_b); - } +return strcmp (name_a, name_b); }
Ditto.
Quoted 8 lines
target-avr/cpu.c +0
-0static void avr_cpu_list_entry (gpointer data,gpointer user_data)target-avr/machine.c +0
-0
target-avr/machine.c static void put_sreg(QEMUFile *f, void *opaque, size_t size) · line 49
Quoted 8 lines
target-avr/machine.c +2
-2@@ -44,8 +44,8 @@ static void put_sreg(QEMUFile *f, void *opaque, size_t size)static const VMStateInfo vms_sreg = { .name ="sreg" , - .get = get_sreg, - .put = put_sreg, + .get = get_sreg, + .put = put_sreg, };
Please don't add code in one patch and then change its formatting in the next patch; just format it correctly to start with.
Otherwise this patch looks OK.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 1/9] target-avr: AVR cores support is added.
In reply to Peter MaydellI remember I did it. So it seems to be a wrong review.
Quoted 107 lines · Peter Maydell
Quoted 12 lines · Michael Rolnik
1. basic CPU structure
2. registers
3. no instructions
4. saving sreg, rampD, rampX, rampY, rampD, eind in HW representationSigned-off-by Michael Rolnik <[email protected]>configure +0
-0configure case "$target_name" in · line 5645
Quoted 5 lines
configure +2
-0@@ -5641,6 +5641,8 @@ case "$target_name" in x86_64) TARGET_BASE_ARCH=i386 ;; + avr) + ;;I asked you to move this in my review of v12, but you haven't.
configure disas_config() { · line 5844
Quoted 10 lines
configure +3
-0alpha) ;; arm|armeb)@@ -5837,6 +5839,9 @@ disas_config() { for i in $ARCH $TARGET_BASE_ARCH ; do case "$i" in + avr) + disas_config "AVR" + ;;Ditto.
configure disas_config() {
Quoted 13 lines
configure +9
-0alpha) disas_config "ALPHA" ;; +#ifndef QEMU_AVR_CPU_QOM_H +#define QEMU_AVR_CPU_QOM_H + +#include "qom/cpu.h" + +#define TYPE_AVR_CPU "avr" + +#define AVR_CPU_CLASS(klass) \ + OBJECT_CLASS_CHECK(AVRCPUClass, (klass),
TYPE_AVR_CPU)configure
Quoted 13 lines
configure +13
-0+#define AVR_CPU(obj) \ + OBJECT_CHECK(AVRCPU, (obj), TYPE_AVR_CPU) +#define AVR_CPU_GET_CLASS(obj) \ + OBJECT_GET_CLASS(AVRCPUClass, (obj), TYPE_AVR_CPU) + +/** +* AVRCPUClass: +* @parent_realize: The parent class' realize handler. +* @parent_reset: The parent class' reset handler. +* @vr: Version Register value. +* +* A AVR CPU model. + */The spacing here is still wrong.
configure
Quoted 13 lines
configure +13
-0+typedef struct AVRCPUClass { + CPUClass parent_class; + + DeviceRealize parent_realize; + void (*parent_reset)(CPUState *cpu); +} AVRCPUClass; + +/** +* AVRCPU: +* @env: #CPUAVRState +* +* A AVR CPU. +*/Ditto.
Quoted 7 lines
configure +7
-0+typedef struct AVRCPU { + /* < private > */ + CPUState parent_obj; + /* < public > */ + + CPUAVRState env; +} AVRCPU;configure
Quoted 10 lines
configure +9
-0+static bool avr_cpu_has_work(CPUState *cs) +{ + AVRCPU *cpu = AVR_CPU(cs); + CPUAVRState *env = &cpu->env; + + return (cs->interrupt_request + & (CPU_INTERRUPT_HARD + | CPU_INTERRUPT_RESET)) + && cpu_interrupts_enabled(env);I asked you to fix this spacing, but it's still all over the place.
If you could check that you've addressed all the comments from previous patch review rounds that would make things faster.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 2/9] target-avr: adding AVR CPU features/flavors
In reply to Peter MaydellRichard. Please stop reviewing it. It seems to be a wrong review.
Quoted 66 lines · Peter Maydell
Quoted 3 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>--- target-avr/cpu.c | 319+++++++++++++++++++++++++++++++++++++++++++++++++--
target-avr/cpu.c static void avr_cpu_class_init(ObjectClass *oc,
Quoted 9 lines
target-avr/cpu.h | 52 ++++++++- target-avr/machine.c | 28 ++--- 3 files changed, 373 insertions(+), 26 deletions(-)target-avr/cpu.c +0
-0@@ -203,9 +203,300 @@ static void avr_cpu_class_init(ObjectClass *oc,void *data)
target-avr/cpu.c static void avr_cpu_class_init(ObjectClass *oc, void *data) · line 206
Quoted 4 lines
target-avr/cpu.c +0
-1dc->cannot_destroy_with_object_finalize_yet = true; } -static void avr_any_initfn (Object *obj)Please don't add code in one patch and then remove it in the next.
target-avr/cpu.c static gint avr_cpu_list_compare(gconstpointer a,
Quoted 1 line
target-avr/cpu.c +0
-0@@ -226,13 +531,7 @@ static gint avr_cpu_list_compare(gconstpointer a,gconstpointer b)
target-avr/cpu.c static gint avr_cpu_list_compare(gconstpointer a, gconstpointer b) · line 535
Quoted 12 lines
target-avr/cpu.c +1
-7name_a =object_class_get_name (class_a); name_b =object_class_get_name (class_b); -if (strcmp (name_a,"any-" TYPE_AVR_CPU ) ==0 ) { -return 1 ; - }else if (strcmp (name_b,"any-" TYPE_AVR_CPU ) ==0 ) { -return -1 ; - }else { -return strcmp (name_a, name_b); - } +return strcmp (name_a, name_b); }Ditto.
target-avr/machine.c static void put_sreg(QEMUFile *f, void *opaque, size_t
Quoted 8 lines
target-avr/cpu.c +0
-0static void avr_cpu_list_entry (gpointer data,gpointer user_data)target-avr/machine.c +0
-0@@ -44,8 +44,8 @@ static void put_sreg(QEMUFile *f, void *opaque, size_tsize)
target-avr/machine.c static void put_sreg(QEMUFile *f, void *opaque, size_t size) · line 49
Quoted 8 lines
target-avr/machine.c +2
-2static const VMStateInfo vms_sreg = { .name ="sreg" , - .get = get_sreg, - .put = put_sreg, + .get = get_sreg, + .put = put_sreg, };Please don't add code in one patch and then change its formatting in the next patch; just format it correctly to start with.
Otherwise this patch looks OK.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 3/9] target-avr: adding a sample AVR board
In reply to Michael RolnikQuoted 80 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>--- MAINTAINERS | 6 +++ hw/avr/Makefile.objs | 21 +++++++++ hw/avr/sample.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.cMAINTAINERS +6
-0@@ -110,6 +110,12 @@ F: disas/arm.c F: disas/arm-a64.cc F: disas/libvixl/ +AVR +M: Michael Rolnik <[email protected]> +S: Maintained +F: target-avr/ +F: hw/avr/ + CRIS M: Edgar E. Iglesias <[email protected]> S: Maintainedhw/avr/Makefile.objs new file +21
-0@@ -0,0 +1,21 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2016 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +obj-y += sample.ohw/avr/sample.c new file +21
-0@@ -0,0 +1,117 @@ +/* +* QEMU AVR CPU +* +* Copyright (c) 2016 Michael Rolnik +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see +* <http://www.gnu.org/licenses/lgpl-2.1.html> +*/ + +/*
hw/avr/sample.c line 31
Quoted 10 lines
hw/avr/sample.c new file +10
-0+* NOTE: +* This is not a real AVR board !!! This is an example !!! +* +* This example can be used to build a real AVR board. +* +* This example board loads provided binary file into flash memory and +* executes it from 0x00000000 address in the code memory space. +* +* This example does not implement/install any AVR specific on board +* devices except SampleIO device which is an example as well.
You forgot to update this comment when you removed the SampleIO device.
Quoted 53 lines
hw/avr/sample.c new file +53
-0+* +* Currently used for AVR CPU validation +* +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "cpu.h" +#include "hw/hw.h" +#include "sysemu/sysemu.h" +#include "sysemu/qtest.h" +#include "ui/console.h" +#include "hw/boards.h" +#include "hw/devices.h" +#include "hw/loader.h" +#include "qemu/error-report.h" +#include "exec/address-spaces.h" +#include "include/hw/sysbus.h" + +#define VIRT_BASE_FLASH 0x00000000 +#define VIRT_BASE_ISRAM 0x00000100 +#define VIRT_BASE_EXMEM 0x00001100 +#define VIRT_BASE_EEPROM 0x00000000 + +#define SIZE_FLASH 0x00020000 +#define SIZE_ISRAM 0x00001000 +#define SIZE_EXMEM 0x00010000 +#define SIZE_EEPROM 0x00001000 +#define SIZE_IOREG SIZE_REGS + +#define PHYS_BASE_FLASH (PHYS_BASE_CODE) + +#define PHYS_BASE_ISRAM (PHYS_BASE_DATA) +#define PHYS_BASE_EXMEM (PHYS_BASE_ISRAM + SIZE_ISRAM) +#define PHYS_BASE_EEPROM (PHYS_BASE_EXMEM + SIZE_EXMEM) + +#define PHYS_BASE_IOREG (PHYS_BASE_REGS + 0x20) + +static void sample_init (MachineState *machine) +{ +MemoryRegion *address_space_mem =get_system_memory (); + +MemoryRegion *ram; +MemoryRegion *flash; +unsigned ram_size =SIZE_ISRAM +SIZE_EXMEM ; + + AVRCPU *cpu_avr ATTRIBUTE_UNUSED; + + ram =g_new (MemoryRegion,1 ); + flash =g_new (MemoryRegion,1 ); + + cpu_avr =cpu_avr_init ("avr5" );
hw/avr/sample.c line 94
Quoted 10 lines
hw/avr/sample.c new file +10
-0+ +memory_region_allocate_system_memory (ram,NULL ,"avr.ram" , ram_size); +memory_region_add_subregion (address_space_mem,PHYS_BASE_ISRAM , ram); + +memory_region_init_rom (flash,NULL ,"avr.flash" ,SIZE_FLASH , &error_fatal); +memory_region_add_subregion (address_space_mem,PHYS_BASE_FLASH , flash); +vmstate_register_ram_global (flash); + +const char *firmware =NULL ; +const char *filename;
Declarations should go at the start of {} blocks, not in the middle (I said this last time too).
Quoted 24 lines
hw/avr/sample.c new file +23
-1+ +if (machine->firmware) { + firmware = machine->firmware; + } + + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , firmware); +if (!filename) { +error_report ("Could not find flash image file '%s'" , firmware); +exit (1 ); + } + +load_image_targphys (filename,PHYS_BASE_FLASH ,SIZE_FLASH ); +} + +static void sample_machine_init (MachineClass *mc) +{ + mc->desc ="AVR sample/example board" ; + mc->init = sample_init; + mc->is_default =1 ; +} + +DEFINE_MACHINE ("sample" , sample_machine_init) + --
Quoted 2 lines
2.4.9 (Apple Git-60)
Otherwise this patch looks OK.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 9/9] target-avr: adding instruction decoder
In reply to Michael RolnikQuoted 4 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>--- target-avr/Makefile.objs | 1 + target-avr/cpugen/src/.cpugen.cpp.swp | Bin 0 -> 24576 bytes
What is this binary ? It looks from the filename like some editor backup file -- is it supposed to be here?
Quoted 44 lines
target-avr/decode.c | 693 +++++++++++++++ target-avr/helper.c | 2 + target-avr/helper.h | 1 + target-avr/translate-inst.c | 1529 +++++++++++++++++---------------- target-avr/translate.c | 29 +- 7 files changed, 1473 insertions(+), 782 deletions(-) create mode 100644 target-avr/cpugen/src/.cpugen.cpp.swp create mode 100644 target-avr/decode.ctarget-avr/helper.c +2
-0@@ -153,6 +153,7 @@ void tlb_fill(CPUState *cs, target_ulong vaddr, MMUAccessType access_type,tlb_set_page_with_attrs (cs, vaddr, paddr, attrs, prot, mmu_idx, page_size); } +void helper_sleep (CPUAVRState *env) {CPUState *cs =CPU (avr_env_get_cpu (env));@@ -160,6 +161,7 @@ void helper_sleep(CPUAVRState *env) cs->exception_index =EXCP_HLT ;cpu_loop_exit (cs); } +void helper_unsupported (CPUAVRState *env) {CPUState *cs =CPU (avr_env_get_cpu (env));target-avr/helper.h +1
-0@@ -26,3 +26,4 @@ DEF_HELPER_3(outb, void, env, i32, i32) DEF_HELPER_2(inb, tl, env, i32) DEF_HELPER_3(fullwr, void, env, i32, i32)DEF_HELPER_2 (fullrd, tl, env, i32) +target-avr/translate-inst.c +0
-0@@ -28,14 +28,14 @@ static void gen_add_CHf(TCGv R, TCGv Rd, TCGv Rr)TCGv t2 =tcg_temp_new_i32 ();
target-avr/translate-inst.c static void gen_add_CHf(TCGv R, TCGv Rd, TCGv Rr) · line 34
Quoted 10 lines
target-avr/translate-inst.c +4
-4TCGv t3 =tcg_temp_new_i32 (); -tcg_gen_and_tl (t1, Rd, Rr);/* t1 = Rd & Rr */ -tcg_gen_andc_tl (t2, Rd,R );/* t2 = Rd & ~R */ -tcg_gen_andc_tl (t3, Rr,R );/* t3 = Rr & ~R */ -tcg_gen_or_tl (t1, t1, t2);/* t1 = t1 | t2 | t3 */ +tcg_gen_and_tl (t1, Rd, Rr);/* t1 = Rd & Rr */ +tcg_gen_andc_tl (t2, Rd,R );/* t2 = Rd & ~R */ +tcg_gen_andc_tl (t3, Rr,R );/* t3 = Rr & ~R */ +tcg_gen_or_tl (t1, t1, t2);/* t1 = t1 | t2 | t3 */
Please don't add code in one patch and then change its spacing in a later patch. Pretty much all of this patch looks like changes that should have been squashed into preceding patches.
thanks
-- PMM
Quoted 5 lines · Michael Rolnik
This series of patches adds 8bit AVR cores to QEMU.
All instruction, except BREAK/DES/SPM/SPMX, are implemented. Not fully tested yet. However I was able to execute simple code with functions. e.g fibonacci calculation. This series of patches include a non real, sample board.
No fuses support yet. PC is set to 0 at reset.
Hi; I have reviewed patches 1-3 (the structure of the CPU and the board) and 9 (which looks like a patch that shouldn't exist). I'm leaving 4-8 (the actual instruction emulation) for rth to review.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 1/9] target-avr: AVR cores support is added.
In reply to Michael RolnikQuoted 1 line · Michael Rolnik
I remember I did it. So it seems to be a wrong review.
Well, it's definitely still in the wrong place in the v14 patchset you sent out: http://patchwork.ozlabs.org/patch/654143/
Did you send out the wrong patchset by mistake?
thanks
-- PMM
Re: [Qemu-devel] [PATCH v14 1/9] target-avr: AVR cores support is added.
I definitely fixed ask your comments from previous review. But as it seems I have done a terrible mistake sending wrong patches. Sorry.
Quoted 10 lines · Peter Maydell
Quoted 1 line · Michael Rolnik
I remember I did it. So it seems to be a wrong review.
Well, it's definitely still in the wrong place in the v14 patchset you sent out: http://patchwork.ozlabs.org/patch/654143/
Did you send out the wrong patchset by mistake?thanks
-- PMM