LatticeMico32 target
cover LatticeMico32 target
This patchset adds support for the LatticeMico32 softcore processor by Lattice Semiconductor.
This is the first part of a larger patchset. It adds target support and two simple BSPs. The second part will add support for the milkymist hardware platform.
PATCH 1/17 LatticeMico32 target support
This patch adds support for the LatticeMico32 softcore processor by Lattice Semiconductor.
--- Makefile.target | 5 + arch_init.c | 2 + arch_init.h | 13 ++-- cpu-exec.c | 13 +++- elf.h | 1 + poison.h | 1 + target-lm32/cpu.h | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++ target-lm32/exec.h | 50 +++++++++++ 8 files changed, 322 insertions(+), 7 deletions(-) create mode 100644 target-lm32/cpu.h create mode 100644 target-lm32/exec.h
Makefile.target +5 -0
@@ -247,6 +247,11 @@ obj-ppc-y += xilinx_timer.o obj-ppc-y += xilinx_uartlite.o obj-ppc-y += xilinx_ethlite.o +# LM32 peripherals +obj-lm32-y += lm32_pic.o +obj-lm32-y += lm32_pic_cpu.o +obj-lm32-y += lm32_juart.o + obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o obj-mips-y += vga.o i8259.o
arch_init.c +2 -0
@@ -64,6 +64,8 @@ const char arch_config_name[] = CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".con#define QEMU_ARCH QEMU_ARCH_I386#elif defined(TARGET_M68K )#define QEMU_ARCH QEMU_ARCH_M68K +#elif defined(TARGET_LM32 ) +#define QEMU_ARCH QEMU_ARCH_LM32#elif defined(TARGET_MICROBLAZE )#define QEMU_ARCH QEMU_ARCH_MICROBLAZE#elif defined(TARGET_MIPS )
arch_init.h +7 -6
@@ -10,12 +10,13 @@ enum {QEMU_ARCH_CRIS =4 ,QEMU_ARCH_I386 =8 ,QEMU_ARCH_M68K =16 , -QEMU_ARCH_MICROBLAZE =32 , -QEMU_ARCH_MIPS =64 , -QEMU_ARCH_PPC =128 , -QEMU_ARCH_S390X =256 , -QEMU_ARCH_SH4 =512 , - QEMU_ARCH_SPARC = 1024, +QEMU_ARCH_LM32 =32 , +QEMU_ARCH_MICROBLAZE =64 , +QEMU_ARCH_MIPS =128 , +QEMU_ARCH_PPC =256 , +QEMU_ARCH_S390X =512 , +QEMU_ARCH_SH4 =1024 , + QEMU_ARCH_SPARC = 2048, };extern const uint32_t arch_type;
cpu-exec.c +12 -1
@@ -263,6 +263,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_ALPHA )#elif defined(TARGET_ARM )#elif defined(TARGET_PPC ) +#elif defined(TARGET_LM32 )#elif defined(TARGET_MICROBLAZE )#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )
@@ -318,6 +319,8 @@ int cpu_exec(CPUState *env1) env->old_exception =-1 ;#elif defined(TARGET_PPC )do_interrupt (env); +#elif defined(TARGET_LM32 ) +do_interrupt (env);#elif defined(TARGET_MICROBLAZE )do_interrupt (env);#elif defined(TARGET_MIPS )
@@ -363,7 +366,7 @@ int cpu_exec(CPUState *env1) }#if defined(TARGET_ARM ) || defined(TARGET_SPARC ) || defined(TARGET_MIPS ) || \ defined(TARGET_PPC ) || defined(TARGET_ALPHA ) || defined(TARGET_CRIS ) || \ - defined(TARGET_MICROBLAZE ) + defined(TARGET_MICROBLAZE ) || defined(TARGET_LM32 )if (interrupt_request &CPU_INTERRUPT_HALT ) { env->interrupt_request &= ~CPU_INTERRUPT_HALT ; env->halted =1 ;
@@ -443,6 +446,13 @@ int cpu_exec(CPUState *env1) env->interrupt_request &= ~CPU_INTERRUPT_HARD ; next_tb =0 ; } +#elif defined(TARGET_LM32 ) +if ((interrupt_request &CPU_INTERRUPT_HARD ) + && (env->ie &IE_IE )) { + env->exception_index =EXCP_IRQ ; +do_interrupt (env); + next_tb =0 ; + }#elif defined(TARGET_MICROBLAZE )if ((interrupt_request &CPU_INTERRUPT_HARD ) && (env->sregs[SR_MSR] & MSR_IE)
@@ -655,6 +665,7 @@ int cpu_exec(CPUState *env1)/* XXX: Save/restore host fpu exception state?. */ #elif defined(TARGET_SPARC )#elif defined(TARGET_PPC ) +#elif defined(TARGET_LM32 )#elif defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ;
elf.h +1 -0
@@ -104,6 +104,7 @@ typedef int64_t Elf64_Sxword;#define EM_H8_300H 47/* Hitachi H8/300H */ #define EM_H8S 48/* Hitachi H8S */ +#define EM_LATTICEMICO32 138/* LatticeMico32 */ /* * This is an interim value that we will use until the committee comes
poison.h +1 -0
@@ -10,6 +10,7 @@#pragma GCC poison TARGET_ALPHA#pragma GCC poison TARGET_ARM#pragma GCC poison TARGET_CRIS +#pragma GCC poison TARGET_LM32#pragma GCC poison TARGET_M68K#pragma GCC poison TARGET_MIPS#pragma GCC poison TARGET_MIPS64
target-lm32/cpu.h new file +244 -0
244 lines not on this page · raw message
target-lm32/exec.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 2/17 lm32: translation routines
In reply to Michael WalleThis patch adds the main translation routine. All opcodes of the LatticeMico32 processor are supported and translated to TCG ops.
--- target-lm32/helper.c | 259 +++++++++ target-lm32/lm32-decode.h | 78 +++ target-lm32/translate.c | 1331 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1668 insertions(+), 0 deletions(-) create mode 100644 target-lm32/helper.c create mode 100644 target-lm32/lm32-decode.h create mode 100644 target-lm32/translate.c
target-lm32/helper.c new file +259 -0
@@ -0,0 +1,259 @@ +/* +* LatticeMico32 helper routines. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#include "config.h" +#include "cpu.h" +#include "exec-all.h" +#include "host-utils.h" + +int cpu_lm32_handle_mmu_fault (CPUState *env,target_ulong address,int rw, +int mmu_idx,int is_softmmu) +{ +int prot; + + address &=TARGET_PAGE_MASK ; + prot =PAGE_BITS ; +if (env->flags &LM32_FLAG_IGNORE_MSB ) { +tlb_set_page (env, address, address &0x7fffffff , prot, mmu_idx, +TARGET_PAGE_SIZE ); + }else { +tlb_set_page (env, address, address, prot, mmu_idx,TARGET_PAGE_SIZE ); + } + +return 0 ; +} + +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr &TARGET_PAGE_MASK ; +} + +void do_interrupt (CPUState *env) +{ +qemu_log_mask (CPU_LOG_INT , +"exception at pc=%x type=%x\n" , env->pc, env->exception_index); + +switch (env->exception_index) { +case EXCP_INSN_BUS_ERROR : +case EXCP_DATA_BUS_ERROR : +case EXCP_DIVIDE_BY_ZERO : +case EXCP_IRQ : +case EXCP_SYSTEMCALL : +/* non-debug exceptions */ + env->regs[R_EA ] = env->pc; + env->ie |= (env->ie &IE_IE ) ?IE_EIE :0 ; + env->ie &= ~IE_IE ; +if (env->dc &DC_RE ) { + env->pc = env->deba + (env->exception_index *32 ); + }else { + env->pc = env->eba + (env->exception_index *32 ); + } +log_cpu_state_mask (CPU_LOG_INT , env,0 ); +break ; +case EXCP_BREAKPOINT : +case EXCP_WATCHPOINT : +/* debug exceptions */ + env->regs[R_BA ] = env->pc; + env->ie |= (env->ie &IE_IE ) ?IE_BIE :0 ; + env->ie &= ~IE_IE ; +if (env->dc &DC_RE ) { + env->pc = env->deba + (env->exception_index *32 ); + }else { + env->pc = env->eba + (env->exception_index *32 ); + } +log_cpu_state_mask (CPU_LOG_INT , env,0 ); +break ; +default : +cpu_abort (env,"unhandled exception type=%d\n" , + env->exception_index); +break ; + } +} + +typedef struct { +const char *name; +uint32_t revision; +uint8_t num_interrupts; +uint8_t num_breakpoints; +uint8_t num_watchpoints; +uint32_t features; +}lm32_def_t ; + +static lm32_def_t lm32_defs[] = { + { + .name ="lm32-basic" , + .revision =3 , + .num_interrupts =32 , + .num_breakpoints =4 , + .num_watchpoints =4 , + .features = (LM32_FEATURE_SHIFT + |LM32_FEATURE_SIGN_EXTEND + |LM32_FEATURE_CYCLE_COUNT ), + }, + { + .name ="lm32-standard" , + .revision =3 , + .num_interrupts =32 , + .num_breakpoints =4 , + .num_watchpoints =4 , + .features = (LM32_FEATURE_MULTIPLY + |LM32_FEATURE_DIVIDE + |LM32_FEATURE_SHIFT + |LM32_FEATURE_SIGN_EXTEND + |LM32_FEATURE_I_CACHE + |LM32_FEATURE_CYCLE_COUNT ), + }, + { + .name ="lm32-full" , + .revision =3 , + .num_interrupts =32 , + .num_breakpoints =4 , + .num_watchpoints =4 , + .features = (LM32_FEATURE_MULTIPLY + |LM32_FEATURE_DIVIDE + |LM32_FEATURE_SHIFT + |LM32_FEATURE_SIGN_EXTEND + |LM32_FEATURE_I_CACHE + |LM32_FEATURE_D_CACHE + |LM32_FEATURE_CYCLE_COUNT ), + } +}; + +void cpu_lm32_list (FILE *f,fprintf_function cpu_fprintf) +{ +int i; + +cpu_fprintf (f,"Available CPUs:\n" ); +for (i =0 ; i <ARRAY_SIZE (lm32_defs); i++) { +cpu_fprintf (f," %s\n" , lm32_defs[i].name); + } +} + +static const lm32_def_t *cpu_lm32_find_by_name (const char *name) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (lm32_defs); i++) { +if (strcasecmp (name, lm32_defs[i].name) ==0 ) { +return &lm32_defs[i]; + } + } + +return NULL ; +} + +static uint32_t cfg_by_def (const lm32_def_t *def) +{ +uint32_t cfg =0 ; + +if (def->features &LM32_FEATURE_MULTIPLY ) { + cfg |=CFG_M ; + } + +if (def->features &LM32_FEATURE_DIVIDE ) { + cfg |=CFG_D ; + } + +if (def->features &LM32_FEATURE_SHIFT ) { + cfg |=CFG_S ; + } + +if (def->features &LM32_FEATURE_SIGN_EXTEND ) { + cfg |=CFG_X ; + } + +if (def->features &LM32_FEATURE_I_CACHE ) { + cfg |=CFG_IC ; + } + +if (def->features &LM32_FEATURE_D_CACHE ) { + cfg |=CFG_DC ; + } + +if (def->features &LM32_FEATURE_CYCLE_COUNT ) { + cfg |=CFG_CC ; + } + + cfg |= (def->num_interrupts <<CFG_INT_SHIFT ); + cfg |= (def->num_breakpoints <<CFG_BP_SHIFT ); + cfg |= (def->num_watchpoints <<CFG_WP_SHIFT ); + cfg |= (def->revision <<CFG_REV_SHIFT ); + +return cfg; +} + +CPUState *cpu_lm32_init (const char *cpu_model) +{ +CPUState *env; +const lm32_def_t *def; +static int tcg_initialized; + + def =cpu_lm32_find_by_name (cpu_model); +if (!def) { +return NULL ; + } + + env =qemu_mallocz (sizeof (CPUState)); + + env->features = def->features; + env->num_bps = def->num_breakpoints; + env->num_wps = def->num_watchpoints; + env->cfg =cfg_by_def (def); + env->flags =0 ; + +cpu_exec_init (env); +cpu_reset (env); + +if (!tcg_initialized) { + tcg_initialized =1 ; +lm32_translate_init (); + } + +return env; +} + +/* Some soc ignores the MSB on the address bus. Thus creating a shadow memory +* area. As a general rule, 0x00000000-0x7fffffff is cached, whereas +* 0x80000000-0xffffffff is not cached and used to access IO devices. */ +void cpu_lm32_set_phys_msb_ignore (CPUState *env,int value) +{ +if (value) { + env->flags |=LM32_FLAG_IGNORE_MSB ; + }else { + env->flags &= ~LM32_FLAG_IGNORE_MSB ; + } +} + +void cpu_reset (CPUState *env) +{ +if (qemu_loglevel_mask (CPU_LOG_RESET )) { +qemu_log ("CPU Reset (CPU %d)\n" , env->cpu_index); +log_cpu_state (env,0 ); + } + +tlb_flush (env,1 ); + +/* reset cpu state */ +memset (env,0 , offsetof(CPULM32State , breakpoints)); +} +
target-lm32/lm32-decode.h new file +78 -0
78 lines not on this page · raw message
target-lm32/translate.c new file +1331 -0
1,331 lines not on this page · raw message
Signature · 1 line
1.7.2.3
[Qemu-devel] Re: [PATCH 02/17] lm32: translation routines
Quoted 4 lines · Michael Walle
This patch adds the main translation routine. All opcodes of the LatticeMico32 processor are supported and translated to TCG ops.
Signed-off-by Michael Walle <[email protected]>
Hi Michael,
Your port looks very nice. I've only got a couple of very small comments.
Quoted 431 lines
--- target-lm32/helper.c | 259 +++++++++ target-lm32/lm32-decode.h | 78 +++ target-lm32/translate.c | 1331 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1668 insertions(+), 0 deletions(-) create mode 100644 target-lm32/helper.c create mode 100644 target-lm32/lm32-decode.h create mode 100644 target-lm32/translate.ctarget-lm32/helper.c new file +259
-0@@ -0,0 +1,259 @@ +/* +* LatticeMico32 helper routines. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#include "config.h" +#include "cpu.h" +#include "exec-all.h" +#include "host-utils.h" + +int cpu_lm32_handle_mmu_fault (CPUState *env,target_ulong address,int rw, +int mmu_idx,int is_softmmu) +{ +int prot; + + address &=TARGET_PAGE_MASK ; + prot =PAGE_BITS ; +if (env->flags &LM32_FLAG_IGNORE_MSB ) { +tlb_set_page (env, address, address &0x7fffffff , prot, mmu_idx, +TARGET_PAGE_SIZE ); + }else { +tlb_set_page (env, address, address, prot, mmu_idx,TARGET_PAGE_SIZE ); + } + +return 0 ; +} + +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr &TARGET_PAGE_MASK ; +} + +void do_interrupt (CPUState *env) +{ +qemu_log_mask (CPU_LOG_INT , +"exception at pc=%x type=%x\n" , env->pc, env->exception_index); + +switch (env->exception_index) { +case EXCP_INSN_BUS_ERROR : +case EXCP_DATA_BUS_ERROR : +case EXCP_DIVIDE_BY_ZERO : +case EXCP_IRQ : +case EXCP_SYSTEMCALL : +/* non-debug exceptions */ + env->regs[R_EA ] = env->pc; + env->ie |= (env->ie &IE_IE ) ?IE_EIE :0 ; + env->ie &= ~IE_IE ; +if (env->dc &DC_RE ) { + env->pc = env->deba + (env->exception_index *32 ); + }else { + env->pc = env->eba + (env->exception_index *32 ); + } +log_cpu_state_mask (CPU_LOG_INT , env,0 ); +break ; +case EXCP_BREAKPOINT : +case EXCP_WATCHPOINT : +/* debug exceptions */ + env->regs[R_BA ] = env->pc; + env->ie |= (env->ie &IE_IE ) ?IE_BIE :0 ; + env->ie &= ~IE_IE ; +if (env->dc &DC_RE ) { + env->pc = env->deba + (env->exception_index *32 ); + }else { + env->pc = env->eba + (env->exception_index *32 ); + } +log_cpu_state_mask (CPU_LOG_INT , env,0 ); +break ; +default : +cpu_abort (env,"unhandled exception type=%d\n" , + env->exception_index); +break ; + } +} + +typedef struct { +const char *name; +uint32_t revision; +uint8_t num_interrupts; +uint8_t num_breakpoints; +uint8_t num_watchpoints; +uint32_t features; +}lm32_def_t ; + +static lm32_def_t lm32_defs[] = { + { + .name ="lm32-basic" , + .revision =3 , + .num_interrupts =32 , + .num_breakpoints =4 , + .num_watchpoints =4 , + .features = (LM32_FEATURE_SHIFT + |LM32_FEATURE_SIGN_EXTEND + |LM32_FEATURE_CYCLE_COUNT ), + }, + { + .name ="lm32-standard" , + .revision =3 , + .num_interrupts =32 , + .num_breakpoints =4 , + .num_watchpoints =4 , + .features = (LM32_FEATURE_MULTIPLY + |LM32_FEATURE_DIVIDE + |LM32_FEATURE_SHIFT + |LM32_FEATURE_SIGN_EXTEND + |LM32_FEATURE_I_CACHE + |LM32_FEATURE_CYCLE_COUNT ), + }, + { + .name ="lm32-full" , + .revision =3 , + .num_interrupts =32 , + .num_breakpoints =4 , + .num_watchpoints =4 , + .features = (LM32_FEATURE_MULTIPLY + |LM32_FEATURE_DIVIDE + |LM32_FEATURE_SHIFT + |LM32_FEATURE_SIGN_EXTEND + |LM32_FEATURE_I_CACHE + |LM32_FEATURE_D_CACHE + |LM32_FEATURE_CYCLE_COUNT ), + } +}; + +void cpu_lm32_list (FILE *f,fprintf_function cpu_fprintf) +{ +int i; + +cpu_fprintf (f,"Available CPUs:\n" ); +for (i =0 ; i <ARRAY_SIZE (lm32_defs); i++) { +cpu_fprintf (f," %s\n" , lm32_defs[i].name); + } +} + +static const lm32_def_t *cpu_lm32_find_by_name (const char *name) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (lm32_defs); i++) { +if (strcasecmp (name, lm32_defs[i].name) ==0 ) { +return &lm32_defs[i]; + } + } + +return NULL ; +} + +static uint32_t cfg_by_def (const lm32_def_t *def) +{ +uint32_t cfg =0 ; + +if (def->features &LM32_FEATURE_MULTIPLY ) { + cfg |=CFG_M ; + } + +if (def->features &LM32_FEATURE_DIVIDE ) { + cfg |=CFG_D ; + } + +if (def->features &LM32_FEATURE_SHIFT ) { + cfg |=CFG_S ; + } + +if (def->features &LM32_FEATURE_SIGN_EXTEND ) { + cfg |=CFG_X ; + } + +if (def->features &LM32_FEATURE_I_CACHE ) { + cfg |=CFG_IC ; + } + +if (def->features &LM32_FEATURE_D_CACHE ) { + cfg |=CFG_DC ; + } + +if (def->features &LM32_FEATURE_CYCLE_COUNT ) { + cfg |=CFG_CC ; + } + + cfg |= (def->num_interrupts <<CFG_INT_SHIFT ); + cfg |= (def->num_breakpoints <<CFG_BP_SHIFT ); + cfg |= (def->num_watchpoints <<CFG_WP_SHIFT ); + cfg |= (def->revision <<CFG_REV_SHIFT ); + +return cfg; +} + +CPUState *cpu_lm32_init (const char *cpu_model) +{ +CPUState *env; +const lm32_def_t *def; +static int tcg_initialized; + + def =cpu_lm32_find_by_name (cpu_model); +if (!def) { +return NULL ; + } + + env =qemu_mallocz (sizeof (CPUState)); + + env->features = def->features; + env->num_bps = def->num_breakpoints; + env->num_wps = def->num_watchpoints; + env->cfg =cfg_by_def (def); + env->flags =0 ; + +cpu_exec_init (env); +cpu_reset (env); + +if (!tcg_initialized) { + tcg_initialized =1 ; +lm32_translate_init (); + } + +return env; +} + +/* Some soc ignores the MSB on the address bus. Thus creating a shadow memory +* area. As a general rule, 0x00000000-0x7fffffff is cached, whereas +* 0x80000000-0xffffffff is not cached and used to access IO devices. */ +void cpu_lm32_set_phys_msb_ignore (CPUState *env,int value) +{ +if (value) { + env->flags |=LM32_FLAG_IGNORE_MSB ; + }else { + env->flags &= ~LM32_FLAG_IGNORE_MSB ; + } +} + +void cpu_reset (CPUState *env) +{ +if (qemu_loglevel_mask (CPU_LOG_RESET )) { +qemu_log ("CPU Reset (CPU %d)\n" , env->cpu_index); +log_cpu_state (env,0 ); + } + +tlb_flush (env,1 ); + +/* reset cpu state */ +memset (env,0 , offsetof(CPULM32State , breakpoints)); +} +target-lm32/lm32-decode.h new file +78
-0@@ -0,0 +1,78 @@ +/* +* LatticeMico32 instruction decoding macros. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +/* Convenient binary macros */ +#define HEX__ (n) 0x##n##LU +#define B8__ (x) (((x&0x0000000FLU) ? 1 : 0) \ + + ((x&0x000000F0LU) ? 2 : 0) \ + + ((x&0x00000F00LU) ? 4 : 0) \ + + ((x&0x0000F000LU) ? 8 : 0) \ + + ((x&0x000F0000LU) ? 16 : 0) \ + + ((x&0x00F00000LU) ? 32 : 0) \ + + ((x&0x0F000000LU) ? 64 : 0) \ + + ((x&0xF0000000LU) ? 128 : 0)) +#define B8 (d) ((unsigned char)B8__(HEX__(d))) + +/* Decode logic, value and mask. */ +#define DEC_ADD {B8(00001101), B8(00011111)} +#define DEC_AND {B8(00001000), B8(00011111)} +#define DEC_ANDHI {B8(00011000), B8(00111111)} +#define DEC_B {B8(00110000), B8(00111111)} +#define DEC_BI {B8(00111000), B8(00111111)} +#define DEC_BE {B8(00010001), B8(00111111)} +#define DEC_BG {B8(00010010), B8(00111111)} +#define DEC_BGE {B8(00010011), B8(00111111)} +#define DEC_BGEU {B8(00010100), B8(00111111)} +#define DEC_BGU {B8(00010101), B8(00111111)} +#define DEC_BNE {B8(00010111), B8(00111111)} +#define DEC_CALL {B8(00110110), B8(00111111)} +#define DEC_CALLI {B8(00111110), B8(00111111)} +#define DEC_CMPE {B8(00011001), B8(00011111)} +#define DEC_CMPG {B8(00011010), B8(00011111)} +#define DEC_CMPGE {B8(00011011), B8(00011111)} +#define DEC_CMPGEU {B8(00011100), B8(00011111)} +#define DEC_CMPGU {B8(00011101), B8(00011111)} +#define DEC_CMPNE {B8(00011111), B8(00011111)} +#define DEC_DIVU {B8(00100011), B8(00111111)} +#define DEC_LB {B8(00000100), B8(00111111)} +#define DEC_LBU {B8(00010000), B8(00111111)} +#define DEC_LH {B8(00000111), B8(00111111)} +#define DEC_LHU {B8(00001011), B8(00111111)} +#define DEC_LW {B8(00001010), B8(00111111)} +#define DEC_MODU {B8(00110001), B8(00111111)} +#define DEC_MUL {B8(00000010), B8(00011111)} +#define DEC_NOR {B8(00000001), B8(00011111)} +#define DEC_OR {B8(00001110), B8(00011111)} +#define DEC_ORHI {B8(00011110), B8(00111111)} +#define DEC_RAISE {B8(00101011), B8(00111111)} +#define DEC_RCSR {B8(00100100), B8(00111111)} +#define DEC_SB {B8(00001100), B8(00111111)} +#define DEC_SEXTB {B8(00101100), B8(00111111)} +#define DEC_SEXTH {B8(00110111), B8(00111111)} +#define DEC_SH {B8(00000011), B8(00111111)} +#define DEC_SL {B8(00001111), B8(00011111)} +#define DEC_SR {B8(00000101), B8(00011111)} +#define DEC_SRU {B8(00000000), B8(00011111)} +#define DEC_SUB {B8(00110010), B8(00111111)} +#define DEC_SW {B8(00010110), B8(00111111)} +#define DEC_USER {B8(00110011), B8(00111111)} +#define DEC_WCSR {B8(00110100), B8(00111111)} +#define DEC_XNOR {B8(00001001), B8(00011111)} +#define DEC_XOR {B8(00000110), B8(00011111)} +target-lm32/translate.c new file +67
-0@@ -0,0 +1,1331 @@ +/* +* LatticeMico32 main translation routines. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include <assert.h> + +#include "cpu.h" +#include "exec-all.h" +#include "disas.h" +#include "helper.h" +#include "tcg-op.h" +#include "lm32-decode.h" +#include "qemu-common.h" + +#include "hw/lm32_pic.h" + +#define GEN_HELPER 1 +#include "helper.h" + +#define DISAS_LM32 1 +#if DISAS_LM32 +# define LOG_DIS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__) +#else +# define LOG_DIS (...) do { } while (0) +#endif + +#define EXTRACT_FIELD (src, start, end) \ + (((src) >> start) & ((1 << (end - start + 1)) - 1)) + +#define MEM_INDEX 0 + +static TCGv_ptr cpu_env; +static TCGv cpu_R[32 ]; +static TCGv cpu_pc; +static TCGv cpu_ie; +static TCGv cpu_icc; +static TCGv cpu_dcc; +static TCGv cpu_cc; +static TCGv cpu_cfg; +static TCGv cpu_eba; +static TCGv cpu_dc; +static TCGv cpu_deba; +static TCGv cpu_bp[4 ]; +static TCGv cpu_wp[4 ]; + +#include "gen-icount.h" +
target-lm32/translate.c line 77
Quoted 10 lines
target-lm32/translate.c new file +10
-0+enum { +OP_FMT_RI , +OP_FMT_RR , +OP_FMT_CR , +OP_FMT_I +}; + +#define JMP_NOJMP 0 +#define JMP_DIRECT 1 +#define JMP_INDIRECT 2
These don't seem to be used, can we remove them?
Quoted 11 lines
target-lm32/translate.c new file +11
-0+ +/* This is the state at translation time. */ +typedef struct DisasContext { + CPUState *env; + target_ulong pc; + + /* Decoder. */ + int format; + uint32_t ir; + uint8_t opcode; + uint8_t r0, r1, r2, csr;
target-lm32/translate.c line 98
Quoted 10 lines
target-lm32/translate.c new file +10
-0+uint16_t imm5; +uint16_t imm16; +uint32_t imm26; + +unsigned int delayed_branch; +unsigned int tb_flags, synced_flags;/* tb dependent flags. */ +int is_jmp; + +unsigned int jmp; +uint32_t jmp_pc;
These too.
target-lm32/translate.c line 100
Quoted 2 lines
target-lm32/translate.c new file +2
-0+ +int nr_nops;
This should probably go aswell..
Quoted 949 lines
target-lm32/translate.c new file +949
-0+struct TranslationBlock *tb; +int singlestep_enabled; +} DisasContext; + +static const char *regnames[] = { +"r0" ,"r1" ,"r2" ,"r3" ,"r4" ,"r5" ,"r6" ,"r7" , +"r8" ,"r9" ,"r10" ,"r11" ,"r12" ,"r13" ,"r14" ,"r15" , +"r16" ,"r17" ,"r18" ,"r19" ,"r20" ,"r21" ,"r22" ,"r23" , +"r24" ,"r25" ,"r26/gp" ,"r27/fp" ,"r28/sp" ,"r29/ra" , +"r30/ea" ,"r31/ba" ,"bp0" ,"bp1" ,"bp2" ,"bp3" ,"wp0" , +"wp1" ,"wp2" ,"wp3" +}; + +static inline int zero_extend (unsigned int val,int width) +{ +return val & ((1 << width) -1 ); +} + +static inline int sign_extend (unsigned int val,int width) +{ +int sval; + +/* LSL. */ + val <<=32 - width; + sval = val; +/* ASR. */ + sval >>=32 - width; + +return sval; +} + +static inline void t_gen_raise_exception (DisasContext *dc,uint32_t index) +{ +TCGv_i32 tmp =tcg_const_i32 (index); + +gen_helper_raise_exception (tmp); +tcg_temp_free_i32 (tmp); +} + +static void gen_goto_tb (DisasContext *dc,int n,target_ulong dest) +{ +TranslationBlock *tb; + + tb = dc->tb; +if ((tb->pc &TARGET_PAGE_MASK ) == (dest &TARGET_PAGE_MASK ) && +likely (!dc->singlestep_enabled)) { +tcg_gen_goto_tb (n); +tcg_gen_movi_tl (cpu_pc, dest); +tcg_gen_exit_tb ((long )tb + n); + }else { +tcg_gen_movi_tl (cpu_pc, dest); +if (dc->singlestep_enabled) { +t_gen_raise_exception (dc,EXCP_DEBUG ); + } +tcg_gen_exit_tb (0 ); + } +} + +static void dec_add (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +if (dc->r0 ==R_R0 ) { +if (dc->r1 ==R_R0 && dc->imm16 ==0 ) { +LOG_DIS ("nop\n" ); + }else { +LOG_DIS ("mvi r%d, %d\n" , dc->r1,sign_extend (dc->imm16,16 )); + } + }else { +LOG_DIS ("addi r%d, r%d, %d\n" , dc->r1, dc->r0, +sign_extend (dc->imm16,16 )); + } + }else { +LOG_DIS ("add r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_addi_tl (cpu_R[dc->r1], cpu_R[dc->r0], +sign_extend (dc->imm16,16 )); + }else { +tcg_gen_add_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); + } +} + +static void dec_and (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("andi r%d, r%d, %d\n" , dc->r1, dc->r0, +zero_extend (dc->imm16,16 )); + }else { +LOG_DIS ("and r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_andi_tl (cpu_R[dc->r1], cpu_R[dc->r0], +zero_extend (dc->imm16,16 )); + }else { +if (dc->r0 ==0 && dc->r1 ==0 && dc->r2 ==0 ) { +tcg_gen_movi_tl (cpu_pc, dc->pc +4 ); +gen_helper_hlt (); + }else { +tcg_gen_and_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); + } + } +} + +static void dec_andhi (DisasContext *dc) +{ +LOG_DIS ("andhi r%d, r%d, %d\n" , dc->r2, dc->r0, dc->imm16); + +tcg_gen_andi_tl (cpu_R[dc->r1], cpu_R[dc->r0], (dc->imm16 <<16 )); +} + +static void dec_b (DisasContext *dc) +{ +if (dc->r0 ==R_RA ) { +LOG_DIS ("ret\n" ); + }else if (dc->r0 ==R_EA ) { +LOG_DIS ("eret\n" ); + }else if (dc->r0 ==R_BA ) { +LOG_DIS ("bret\n" ); + }else { +LOG_DIS ("b r%d\n" , dc->r0); + } + +/* restore IE.IE in case of an eret */ +if (dc->r0 ==R_EA ) { +TCGv t0 =tcg_temp_new (); +int l1 =gen_new_label (); +tcg_gen_andi_tl (t0, cpu_ie,IE_EIE ); +tcg_gen_ori_tl (cpu_ie, cpu_ie,IE_IE ); +tcg_gen_brcondi_tl (TCG_COND_EQ , t0,IE_EIE , l1); +tcg_gen_andi_tl (cpu_ie, cpu_ie, ~IE_IE ); +gen_set_label (l1); +tcg_temp_free (t0); + }else if (dc->r0 ==R_BA ) { +TCGv t0 =tcg_temp_new (); +int l1 =gen_new_label (); +tcg_gen_andi_tl (t0, cpu_ie,IE_BIE ); +tcg_gen_ori_tl (cpu_ie, cpu_ie,IE_IE ); +tcg_gen_brcondi_tl (TCG_COND_EQ , t0,IE_BIE , l1); +tcg_gen_andi_tl (cpu_ie, cpu_ie, ~IE_IE ); +gen_set_label (l1); +tcg_temp_free (t0); + } +tcg_gen_mov_tl (cpu_pc, cpu_R[dc->r0]); + + dc->is_jmp =DISAS_JUMP ; +} + +static void dec_bi (DisasContext *dc) +{ +LOG_DIS ("bi %d\n" ,sign_extend (dc->imm26 <<2 ,26 )); + +gen_goto_tb (dc,0 , dc->pc + (sign_extend (dc->imm26 <<2 ,26 ))); + + dc->is_jmp =DISAS_TB_JUMP ; +} + +static inline void gen_cond_branch (DisasContext *dc,int cond) +{ +int l1; + + l1 =gen_new_label (); +tcg_gen_brcond_tl (cond, cpu_R[dc->r0], cpu_R[dc->r1], l1); +gen_goto_tb (dc,0 , dc->pc +4 ); +gen_set_label (l1); +gen_goto_tb (dc,1 , dc->pc + (sign_extend (dc->imm16 <<2 ,16 ))); + dc->is_jmp =DISAS_TB_JUMP ; +} + +static void dec_be (DisasContext *dc) +{ +LOG_DIS ("be r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 ) *4 ); + +gen_cond_branch (dc,TCG_COND_EQ ); +} + +static void dec_bg (DisasContext *dc) +{ +LOG_DIS ("bg r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 *4 )); + +gen_cond_branch (dc,TCG_COND_GT ); +} + +static void dec_bge (DisasContext *dc) +{ +LOG_DIS ("bge r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 ) *4 ); + +gen_cond_branch (dc,TCG_COND_GE ); +} + +static void dec_bgeu (DisasContext *dc) +{ +LOG_DIS ("bgeu r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 ) *4 ); + +gen_cond_branch (dc,TCG_COND_GEU ); +} + +static void dec_bgu (DisasContext *dc) +{ +LOG_DIS ("bgu r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 ) *4 ); + +gen_cond_branch (dc,TCG_COND_GTU ); +} + +static void dec_bne (DisasContext *dc) +{ +LOG_DIS ("bne r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 ) *4 ); + +gen_cond_branch (dc,TCG_COND_NE ); +} + +static void dec_call (DisasContext *dc) +{ +LOG_DIS ("call r%d\n" , dc->r0); + +tcg_gen_movi_tl (cpu_R[R_RA ], dc->pc +4 ); +tcg_gen_mov_tl (cpu_pc, cpu_R[dc->r0]); + + dc->is_jmp =DISAS_JUMP ; +} + +static void dec_calli (DisasContext *dc) +{ +LOG_DIS ("calli %d\n" ,sign_extend (dc->imm26,26 ) *4 ); + +tcg_gen_movi_tl (cpu_R[R_RA ], dc->pc +4 ); +gen_goto_tb (dc,0 , dc->pc + (sign_extend (dc->imm26 <<2 ,26 ))); + + dc->is_jmp =DISAS_TB_JUMP ; +} + +static inline void gen_compare (DisasContext *dc,int cond) +{ +int rX = (dc->format ==OP_FMT_RR ) ? dc->r2 : dc->r1; +int rY = (dc->format ==OP_FMT_RR ) ? dc->r0 : dc->r0; +int rZ = (dc->format ==OP_FMT_RR ) ? dc->r1 :-1 ; + +int l1, l2; + + l1 =gen_new_label (); + l2 =gen_new_label (); + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_brcondi_tl (cond, cpu_R[rY],sign_extend (dc->imm16,16 ), l1); + }else { +tcg_gen_brcond_tl (cond, cpu_R[rY], cpu_R[rZ], l1); + } +tcg_gen_movi_tl (cpu_R[rX],0 ); +tcg_gen_br (l2); +gen_set_label (l1); +tcg_gen_movi_tl (cpu_R[rX],1 ); +gen_set_label (l2); +} + +static void dec_cmpe (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("cmpei r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("cmpe r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +gen_compare (dc,TCG_COND_EQ ); +} + +static void dec_cmpg (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("cmpgi r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("cmpg r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +gen_compare (dc,TCG_COND_GT ); +} + +static void dec_cmpge (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("cmpgei r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("cmpge r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +gen_compare (dc,TCG_COND_GE ); +} + +static void dec_cmpgeu (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("cmpgeui r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("cmpgeu r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +gen_compare (dc,TCG_COND_GEU ); +} + +static void dec_cmpgu (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("cmpgui r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("cmpgu r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +gen_compare (dc,TCG_COND_GTU ); +} + +static void dec_cmpne (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("cmpnei r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("cmpne r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +gen_compare (dc,TCG_COND_NE ); +} + +static void dec_divu (DisasContext *dc) +{ +int l1; + +LOG_DIS ("divu r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + +if (!(dc->env->features &LM32_FEATURE_DIVIDE )) { +cpu_abort (dc->env,"hardware divider is not available\n" ); + } + + l1 =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_NE , cpu_R[dc->r1],0 , l1); +tcg_gen_movi_tl (cpu_pc, dc->pc); +t_gen_raise_exception (dc,EXCP_DIVIDE_BY_ZERO ); +gen_set_label (l1); +tcg_gen_divu_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +} + +static void dec_lb (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("lb r%d, (r%d+%d)\n" , dc->r1, dc->r0, dc->imm16); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_ld8s (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_lbu (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("lbu r%d, (r%d+%d)\n" , dc->r1, dc->r0, dc->imm16); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_ld8u (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_lh (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("lh r%d, (r%d+%d)\n" , dc->r1, dc->r0, dc->imm16); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_ld16s (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_lhu (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("lhu r%d, (r%d+%d)\n" , dc->r1, dc->r0, dc->imm16); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_ld16u (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_lw (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("lw r%d, (r%d+%d)\n" , dc->r1, dc->r0,sign_extend (dc->imm16,16 )); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_ld32s (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_modu (DisasContext *dc) +{ +int l1; + +LOG_DIS ("modu r%d, r%d, %d\n" , dc->r2, dc->r0, dc->r1); + +if (!(dc->env->features &LM32_FEATURE_DIVIDE )) { +cpu_abort (dc->env,"hardware divider is not available\n" ); + } + + l1 =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_NE , cpu_R[dc->r1],0 , l1); +tcg_gen_movi_tl (cpu_pc, dc->pc); +t_gen_raise_exception (dc,EXCP_DIVIDE_BY_ZERO ); +gen_set_label (l1); +tcg_gen_remu_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +} + +static void dec_mul (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("muli r%d, r%d, %d\n" , dc->r0, dc->r1, +sign_extend (dc->imm16,16 )); + }else { +LOG_DIS ("mul r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (!(dc->env->features &LM32_FEATURE_MULTIPLY )) { +cpu_abort (dc->env,"hardware multiplier is not available\n" ); + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_muli_tl (cpu_R[dc->r1], cpu_R[dc->r0], +sign_extend (dc->imm16,16 )); + }else { +tcg_gen_mul_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); + } +} + +static void dec_nor (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("nori r%d, r%d, %d\n" , dc->r0, dc->r1, +zero_extend (dc->imm16,16 )); + }else { +LOG_DIS ("nor r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (dc->format ==OP_FMT_RI ) { +TCGv t0 =tcg_temp_new (); +tcg_gen_movi_tl (t0,zero_extend (dc->imm16,16 )); +tcg_gen_nor_tl (cpu_R[dc->r1], cpu_R[dc->r0], t0); +tcg_temp_free (t0); + }else { +tcg_gen_nor_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); + } +} + +static void dec_or (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("ori r%d, r%d, %d\n" , dc->r1, dc->r0, +zero_extend (dc->imm16,16 )); + }else { +if (dc->r1 ==R_R0 ) { +LOG_DIS ("mv r%d, r%d\n" , dc->r2, dc->r0); + }else { +LOG_DIS ("or r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_ori_tl (cpu_R[dc->r1], cpu_R[dc->r0], +zero_extend (dc->imm16,16 )); + }else { +tcg_gen_or_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); + } +} + +static void dec_orhi (DisasContext *dc) +{ +if (dc->r0 ==R_R0 ) { +LOG_DIS ("mvhi r%d, %d\n" , dc->r1, dc->imm16); + }else { +LOG_DIS ("orhi r%d, r%d, %d\n" , dc->r1, dc->r0, dc->imm16); + } + +tcg_gen_ori_tl (cpu_R[dc->r1], cpu_R[dc->r0], (dc->imm16 <<16 )); +} + +static void dec_raise (DisasContext *dc) +{ +TCGv t0; +int l1; + +if (dc->imm5 ==7 ) { +LOG_DIS ("scall\n" ); + }else if (dc->imm5 ==2 ) { +LOG_DIS ("break\n" ); + }else { +cpu_abort (dc->env,"invalid opcode\n" ); + } + + t0 =tcg_temp_new (); + l1 =gen_new_label (); + +/* save IE.IE */ +tcg_gen_andi_tl (t0, cpu_ie,IE_IE ); + +/* IE.IE = 0 */ +tcg_gen_andi_tl (cpu_ie, cpu_ie, ~IE_IE ); + +if (dc->imm5 ==7 ) { +/* IE.EIE = IE.IE */ +tcg_gen_ori_tl (cpu_ie, cpu_ie,IE_EIE ); +tcg_gen_brcondi_tl (TCG_COND_EQ , t0,IE_IE , l1); +tcg_gen_andi_tl (cpu_ie, cpu_ie, ~IE_EIE ); +gen_set_label (l1); + +/* gpr[ea] = PC */ +tcg_gen_movi_tl (cpu_R[R_EA ], dc->pc); +tcg_temp_free (t0); + +tcg_gen_movi_tl (cpu_pc, dc->pc); +t_gen_raise_exception (dc,EXCP_SYSTEMCALL ); + }else { +/* IE.BIE = IE.IE */ +tcg_gen_ori_tl (cpu_ie, cpu_ie,IE_BIE ); +tcg_gen_brcondi_tl (TCG_COND_EQ , t0,IE_IE , l1); +tcg_gen_andi_tl (cpu_ie, cpu_ie, ~IE_BIE ); +gen_set_label (l1); + +/* gpr[ba] = PC */ +tcg_gen_movi_tl (cpu_R[R_BA ], dc->pc); +tcg_temp_free (t0); + +tcg_gen_movi_tl (cpu_pc, dc->pc); +t_gen_raise_exception (dc,EXCP_BREAKPOINT ); + } +} + +static void dec_rcsr (DisasContext *dc) +{ +LOG_DIS ("rcsr r%d, %d\n" , dc->r2, dc->csr); + +switch (dc->csr) { +case CSR_IE : +tcg_gen_mov_tl (cpu_R[dc->r2], cpu_ie); +break ; +case CSR_IM : +gen_helper_rcsr_im (cpu_R[dc->r2]); +break ; +case CSR_IP : +gen_helper_rcsr_ip (cpu_R[dc->r2]); +break ; +case CSR_CC : +tcg_gen_mov_tl (cpu_R[dc->r2], cpu_cc); +break ; +case CSR_CFG : +tcg_gen_mov_tl (cpu_R[dc->r2], cpu_cfg); +break ; +case CSR_EBA : +tcg_gen_mov_tl (cpu_R[dc->r2], cpu_eba); +break ; +case CSR_DC : +tcg_gen_mov_tl (cpu_R[dc->r2], cpu_dc); +break ; +case CSR_DEBA : +tcg_gen_mov_tl (cpu_R[dc->r2], cpu_deba); +break ; +case CSR_JTX : +gen_helper_rcsr_jtx (cpu_R[dc->r2]); +break ; +case CSR_JRX : +gen_helper_rcsr_jrx (cpu_R[dc->r2]); +break ; +case CSR_ICC : +case CSR_DCC : +case CSR_BP0 : +case CSR_BP1 : +case CSR_BP2 : +case CSR_BP3 : +case CSR_WP0 : +case CSR_WP1 : +case CSR_WP2 : +case CSR_WP3 : +cpu_abort (dc->env,"invalid read access csr=%x\n" , dc->csr); +break ; +default : +cpu_abort (dc->env,"read_csr: unknown csr=%x\n" , dc->csr); +break ; + } +} + +static void dec_sb (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("sb (r%d+%d), r%d\n" , dc->r0, dc->imm16, dc->r1); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_st8 (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_sextb (DisasContext *dc) +{ +LOG_DIS ("sextb r%d, r%d\n" , dc->r2, dc->r0); + +if (!(dc->env->features &LM32_FEATURE_SIGN_EXTEND )) { +cpu_abort (dc->env,"hardware sign extender is not available\n" ); + } + +tcg_gen_ext8s_tl (cpu_R[dc->r2], cpu_R[dc->r0]); +} + +static void dec_sexth (DisasContext *dc) +{ +LOG_DIS ("sexth r%d, r%d\n" , dc->r2, dc->r0); + +if (!(dc->env->features &LM32_FEATURE_SIGN_EXTEND )) { +cpu_abort (dc->env,"hardware sign extender is not available\n" ); + } + +tcg_gen_ext16s_tl (cpu_R[dc->r2], cpu_R[dc->r0]); +} + +static void dec_sh (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("sh (r%d+%d), r%d\n" , dc->r0, dc->imm16, dc->r1); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_st16 (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_sl (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("sli r%d, r%d, %d\n" , dc->r1, dc->r0, dc->imm5); + }else { +LOG_DIS ("sl r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (!(dc->env->features &LM32_FEATURE_SHIFT )) { +cpu_abort (dc->env,"hardware shifter is not available\n" ); + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_shli_tl (cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); + }else { +TCGv t0 =tcg_temp_new (); +tcg_gen_andi_tl (t0, cpu_R[dc->r1],0x1f ); +tcg_gen_shl_tl (cpu_R[dc->r2], cpu_R[dc->r0], t0); +tcg_temp_free (t0); + } +} + +static void dec_sr (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("sri r%d, r%d, %d\n" , dc->r1, dc->r0, dc->imm5); + }else { +LOG_DIS ("sr r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (!(dc->env->features &LM32_FEATURE_SHIFT )) { +if (dc->format ==OP_FMT_RI ) { +/* TODO: check r1 == 1 during runtime */ + }else { +if (dc->imm5 !=1 ) { +cpu_abort (dc->env,"hardware shifter is not available\n" ); + } + } + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_sari_tl (cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); + }else { +TCGv t0 =tcg_temp_new (); +tcg_gen_andi_tl (t0, cpu_R[dc->r1],0x1f ); +tcg_gen_sar_tl (cpu_R[dc->r2], cpu_R[dc->r0], t0); +tcg_temp_free (t0); + } +} + +static void dec_sru (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("srui r%d, r%d, %d\n" , dc->r1, dc->r0, dc->imm5); + }else { +LOG_DIS ("sru r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (!(dc->env->features &LM32_FEATURE_SHIFT )) { +if (dc->format ==OP_FMT_RI ) { +/* TODO: check r1 == 1 during runtime */ + }else { +if (dc->imm5 !=1 ) { +cpu_abort (dc->env,"hardware shifter is not available\n" ); + } + } + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_shri_tl (cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); + }else { +TCGv t0 =tcg_temp_new (); +tcg_gen_andi_tl (t0, cpu_R[dc->r1],0x1f ); +tcg_gen_shr_tl (cpu_R[dc->r2], cpu_R[dc->r0], t0); +tcg_temp_free (t0); + } +} + +static void dec_sub (DisasContext *dc) +{ +LOG_DIS ("sub r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + +tcg_gen_sub_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +} + +static void dec_sw (DisasContext *dc) +{ +TCGv t0; + +LOG_DIS ("sw (r%d+%d), r%d\n" , dc->r0,sign_extend (dc->imm16,16 ), dc->r1); + + t0 =tcg_temp_new (); +tcg_gen_addi_tl (t0, cpu_R[dc->r0],sign_extend (dc->imm16,16 )); +tcg_gen_qemu_st32 (cpu_R[dc->r1], t0,MEM_INDEX ); +tcg_temp_free (t0); +} + +static void dec_user (DisasContext *dc) +{ +LOG_DIS ("user" ); + +cpu_abort (dc->env,"user insn undefined\n" ); +} + +static void dec_wcsr (DisasContext *dc) +{ +int no; + +LOG_DIS ("wcsr r%d, %d\n" , dc->r1, dc->csr); + +switch (dc->csr) { +case CSR_IE : +tcg_gen_mov_tl (cpu_ie, cpu_R[dc->r1]); +tcg_gen_movi_tl (cpu_pc, dc->pc +4 ); + dc->is_jmp =DISAS_UPDATE ; +break ; +case CSR_IM : +/* mark as an io operation because it could cause an interrupt */ +if (use_icount) { +gen_io_start (); + } +gen_helper_wcsr_im (cpu_R[dc->r1]); +tcg_gen_movi_tl (cpu_pc, dc->pc +4 ); +if (use_icount) { +gen_io_end (); + } + dc->is_jmp =DISAS_UPDATE ; +break ; +case CSR_IP : +/* mark as an io operation because it could cause an interrupt */ +if (use_icount) { +gen_io_start (); + } +gen_helper_wcsr_ip (cpu_R[dc->r1]); +tcg_gen_movi_tl (cpu_pc, dc->pc +4 ); +if (use_icount) { +gen_io_end (); + } + dc->is_jmp =DISAS_UPDATE ; +break ; +case CSR_ICC : +/* TODO */ +break ; +case CSR_DCC : +/* TODO */ +break ; +case CSR_EBA : +tcg_gen_mov_tl (cpu_eba, cpu_R[dc->r1]); +break ; +case CSR_DEBA : +tcg_gen_mov_tl (cpu_deba, cpu_R[dc->r1]); +break ; +case CSR_JTX : +gen_helper_wcsr_jtx (cpu_R[dc->r1]); +break ; +case CSR_JRX : +gen_helper_wcsr_jrx (cpu_R[dc->r1]); +break ; +case CSR_DC : +tcg_gen_mov_tl (cpu_dc, cpu_R[dc->r1]); +break ; +case CSR_BP0 : +case CSR_BP1 : +case CSR_BP2 : +case CSR_BP3 : + no = dc->csr -CSR_BP0 ; +if (dc->env->num_bps <= no) { +cpu_abort (dc->env,"breakpoint #%i is not available\n" , no); + } +tcg_gen_mov_tl (cpu_bp[no], cpu_R[dc->r1]); +break ; +case CSR_WP0 : +case CSR_WP1 : +case CSR_WP2 : +case CSR_WP3 : + no = dc->csr -CSR_WP0 ; +if (dc->env->num_wps <= no) { +cpu_abort (dc->env,"watchpoint #%i is not available\n" , no); + } +tcg_gen_mov_tl (cpu_wp[no], cpu_R[dc->r1]); +break ; +case CSR_CC : +case CSR_CFG : +cpu_abort (dc->env,"invalid write access csr=%x\n" , dc->csr); +break ; +default : +cpu_abort (dc->env,"write_csr unknown csr=%x\n" , dc->csr); +break ; + } +} + +static void dec_xnor (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("xnori r%d, r%d, %d\n" , dc->r0, dc->r1, +zero_extend (dc->imm16,16 )); + }else { +if (dc->r1 ==R_R0 ) { +LOG_DIS ("not r%d, r%d\n" , dc->r2, dc->r0); + }else { +LOG_DIS ("xnor r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_xori_tl (cpu_R[dc->r1], cpu_R[dc->r0], +zero_extend (dc->imm16,16 )); +tcg_gen_not_tl (cpu_R[dc->r1], cpu_R[dc->r1]); + }else { +tcg_gen_xor_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +tcg_gen_not_tl (cpu_R[dc->r2], cpu_R[dc->r2]); + } +} + +static void dec_xor (DisasContext *dc) +{ +if (dc->format ==OP_FMT_RI ) { +LOG_DIS ("xori r%d, r%d, %d\n" , dc->r0, dc->r1, +zero_extend (dc->imm16,16 )); + }else { +LOG_DIS ("xor r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); + } + +if (dc->format ==OP_FMT_RI ) { +tcg_gen_xori_tl (cpu_R[dc->r1], cpu_R[dc->r0], +zero_extend (dc->imm16,16 )); + }else { +tcg_gen_xor_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); + } +} + +static struct decoder_info { +struct { +uint32_t bits; +uint32_t mask; + }; +void (*dec)(DisasContext *dc); +} decinfo[] = { + {DEC_ADD , dec_add}, + {DEC_AND , dec_and}, + {DEC_ANDHI , dec_andhi}, + {DEC_B , dec_b}, + {DEC_BI , dec_bi}, + {DEC_BE , dec_be}, + {DEC_BG , dec_bg}, + {DEC_BGE , dec_bge}, + {DEC_BGEU , dec_bgeu}, + {DEC_BGU , dec_bgu}, + {DEC_BNE , dec_bne}, + {DEC_CALL , dec_call}, + {DEC_CALLI , dec_calli}, + {DEC_CMPE , dec_cmpe}, + {DEC_CMPG , dec_cmpg}, + {DEC_CMPGE , dec_cmpge}, + {DEC_CMPGEU , dec_cmpgeu}, + {DEC_CMPGU , dec_cmpgu}, + {DEC_CMPNE , dec_cmpne}, + {DEC_DIVU , dec_divu}, + {DEC_LB , dec_lb}, + {DEC_LBU , dec_lbu}, + {DEC_LH , dec_lh}, + {DEC_LHU , dec_lhu}, + {DEC_LW , dec_lw}, + {DEC_MODU , dec_modu}, + {DEC_MUL , dec_mul}, + {DEC_NOR , dec_nor}, + {DEC_OR , dec_or}, + {DEC_ORHI , dec_orhi}, + {DEC_RAISE , dec_raise}, + {DEC_RCSR , dec_rcsr}, + {DEC_SB , dec_sb}, + {DEC_SEXTB , dec_sextb}, + {DEC_SEXTH , dec_sexth}, + {DEC_SH , dec_sh}, + {DEC_SL , dec_sl}, + {DEC_SR , dec_sr}, + {DEC_SRU , dec_sru}, + {DEC_SUB , dec_sub}, + {DEC_SW , dec_sw}, + {DEC_USER , dec_user}, + {DEC_WCSR , dec_wcsr}, + {DEC_XNOR , dec_xnor}, + {DEC_XOR , dec_xor}, +}; + +static inline void decode (DisasContext *dc) +{ +uint32_t ir; +int i; + +if (unlikely (qemu_loglevel_mask (CPU_LOG_TB_OP ))) { +tcg_gen_debug_insn_start (dc->pc); + } + + dc->ir = ir =ldl_code (dc->pc); +LOG_DIS ("%8.8x\t" , dc->ir); + +/* try guessing 'empty' instruction memory, although it may be a valid
target-lm32/translate.c line 1059
Quoted 10 lines
target-lm32/translate.c new file +10
-0+* instruction sequence (eg. srui r0, r0, 0) */ +if (dc->ir) { + dc->nr_nops =0 ; + }else { +LOG_DIS ("nr_nops=%d\t" , dc->nr_nops); + dc->nr_nops++; +if (dc->nr_nops >4 ) { +cpu_abort (dc->env,"fetching nop sequence\n" ); + } + }
This nop sequence detection should probably go away. A reminder for me too to remove it from the microblaze port (from where I guess you inherited it)..
Cheers
[Qemu-devel] Re: [PATCH 02/17] lm32: translation routines
Hi Edgar.
first of all let me thank you for the review.
Quoted 5 lines · Edgar E. Iglesias
target-lm32/translate.c line 77
Quoted 3 lines
target-lm32/translate.c new file +3
-0+#define JMP_NOJMP 0 +#define JMP_DIRECT 1 +#define JMP_INDIRECT 2These don't seem to be used, can we remove them?
Good catch :) I'll remove them.
Quoted 15 lines
Quoted 15 lines
target-lm32/translate.c new file +15
-0+ +/* This is the state at translation time. */ +typedef struct DisasContext { + CPUState *env; + target_ulong pc; + + /* Decoder. */ + int format; + uint32_t ir; + uint8_t opcode; + uint8_t r0, r1, r2, csr; + uint16_t imm5; + uint16_t imm16; + uint32_t imm26; +
Quoted 8 lines
target-lm32/translate.c line 98
Quoted 6 lines
target-lm32/translate.c new file +6
-0+unsigned int delayed_branch; +unsigned int tb_flags, synced_flags;/* tb dependent flags. */ +int is_jmp; + +unsigned int jmp; +uint32_t jmp_pc;These too.
Ditto.
Quoted 4 lines
target-lm32/translate.c line 100
Quoted 2 lines
target-lm32/translate.c new file +2
-0+ +int nr_nops;This should probably go aswell..
See below.
Quoted 12 lines
target-lm32/translate.c line 1059
Quoted 11 lines
+ /* try guessing 'empty' instruction memory, although it may be a
valid + * instruction sequence (eg. srui r0, r0, 0) */target-lm32/translate.c new file +9
-0+if (dc->ir) { + dc->nr_nops =0 ; + }else { +LOG_DIS ("nr_nops=%d\t" , dc->nr_nops); + dc->nr_nops++; +if (dc->nr_nops >4 ) { +cpu_abort (dc->env,"fetching nop sequence\n" ); + } + }
Quoted 3 lines
This nop sequence detection should probably go away. A reminder for me too to remove it from the microblaze port (from where I guess you inherited it)..
I've always found this 'feature' handy, esp when you are porting new software. Is there any particular reason why this should be removed? Besides the fact that it won't match the real hardware if those instructions are executed. In the case of the LM32, these are really nonsense instructions (shift r0 right by 0, r0 is by definition 0).
Signature · 1 line
Michael
[Qemu-devel] Re: [PATCH 02/17] lm32: translation routines
Quoted 55 lines · Michael Walle
Hi Edgar.
first of all let me thank you for the review.
Quoted 5 lines · Edgar E. Iglesias
target-lm32/translate.c line 77
Quoted 3 lines
target-lm32/translate.c new file +3
-0+#define JMP_NOJMP 0 +#define JMP_DIRECT 1 +#define JMP_INDIRECT 2These don't seem to be used, can we remove them?
Good catch :) I'll remove them.
Quoted 15 lines
Quoted 15 lines
target-lm32/translate.c new file +15
-0+ +/* This is the state at translation time. */ +typedef struct DisasContext { + CPUState *env; + target_ulong pc; + + /* Decoder. */ + int format; + uint32_t ir; + uint8_t opcode; + uint8_t r0, r1, r2, csr; + uint16_t imm5; + uint16_t imm16; + uint32_t imm26; +Quoted 8 lines
target-lm32/translate.c line 98
Quoted 6 lines
target-lm32/translate.c new file +6
-0+unsigned int delayed_branch; +unsigned int tb_flags, synced_flags;/* tb dependent flags. */ +int is_jmp; + +unsigned int jmp; +uint32_t jmp_pc;These too.
Ditto.
Quoted 4 lines
target-lm32/translate.c line 100
Quoted 2 lines
target-lm32/translate.c new file +2
-0+ +int nr_nops;This should probably go aswell..
See below.
Quoted 12 lines
Quoted 11 lines
+ /* try guessing 'empty' instruction memory, although it may be a
valid + * instruction sequence (eg. srui r0, r0, 0) */target-lm32/translate.c new file +9
-0+if (dc->ir) { + dc->nr_nops =0 ; + }else { +LOG_DIS ("nr_nops=%d\t" , dc->nr_nops); + dc->nr_nops++; +if (dc->nr_nops >4 ) { +cpu_abort (dc->env,"fetching nop sequence\n" ); + } + }
Quoted 8 lines
Quoted 3 lines
This nop sequence detection should probably go away. A reminder for me too to remove it from the microblaze port (from where I guess you inherited it)..
I've always found this 'feature' handy, esp when you are porting new software. Is there any particular reason why this should be removed? Besides the fact that it won't match the real hardware if those instructions are executed. In the case of the LM32, these are really nonsense instructions (shift r0 right by 0, r0 is by definition 0).
Yes, I found the nop tracking handy too but It exposes a way for guests to completely abort the vm with valid code. On microblaze, even guest userspace can trig the cpu_abort. Your port doesn't have an MMU so guest userland can probably kill the vm anyway, so it might be less of an issue.
Maybe the event could be logged instead of cpu_abort:ed?
Anyway, I don't think this is a showstopper preventing your port from going upstream. If you insist and none of the other maintainers feel strongly about it, I'm ok with it too.
Cheers
[Qemu-devel] Re: [PATCH 02/17] lm32: translation routines
Quoted 6 lines · Edgar E. Iglesias
Yes, I found the nop tracking handy too but It exposes a way for guests to completely abort the vm with valid code. On microblaze, even guest userspace can trig the
cpu_abort. Your port doesn't have an MMU so guest userland can probably kill the vm anyway, so it might be less of an issue.Maybe the event could be logged instead of cpu_abort:ed?
If the program jumps to uninitialized memory, it'll likely execute until the end of the memory and then kill the VM.
Maybe we can add some kind of runtime configuration option for enabling/disabling this?
Signature · 1 line
Michael
[Qemu-devel] Re: [PATCH 02/17] lm32: translation routines
Quoted 11 lines · Michael Walle
Quoted 6 lines · Edgar E. Iglesias
Yes, I found the nop tracking handy too but It exposes a way for guests to completely abort the vm with valid code. On microblaze, even guest userspace can trig the
cpu_abort. Your port doesn't have an MMU so guest userland can probably kill the vm anyway, so it might be less of an issue.Maybe the event could be logged instead of cpu_abort:ed?
If the program jumps to uninitialized memory, it'll likely execute until the end of the memory and then kill the VM.
Maybe we can add some kind of runtime configuration option for enabling/disabling this?
During the first few reviews I stumbled over this too and actually found it a pretty slick hack. I agree though that it'd be nice to have a machine switch. Don't we have some machine config options these days? Alternatively, it could even be a -cpu flag.
Alex
Re: [Qemu-devel] [PATCH 02/17] lm32: translation routines
In reply to Michael Walletarget-lm32/translate.c line 359
Quoted 10 lines · Michael Walle
target-lm32/translate.c new file +10
-0+if (dc->format ==OP_FMT_RI ) { +tcg_gen_brcondi_tl (cond, cpu_R[rY],sign_extend (dc->imm16,16 ), l1); + }else { +tcg_gen_brcond_tl (cond, cpu_R[rY], cpu_R[rZ], l1); + } +tcg_gen_movi_tl (cpu_R[rX],0 ); +tcg_gen_br (l2); +gen_set_label (l1); +tcg_gen_movi_tl (cpu_R[rX],1 ); +gen_set_label (l2);
This is tcg_gen_setcond_tl.
BTW, why the extensive extra LOG_DIS code? Why not just run the regular disassembler, like other ports?
target-lm32/translate.c line 541
Quoted 3 lines
target-lm32/translate.c new file +3
-0+if (!(dc->env->features &LM32_FEATURE_MULTIPLY )) { +cpu_abort (dc->env,"hardware multiplier is not available\n" ); + }
Aborting the VM, rather than raising an exception?
target-lm32/translate.c line 962
Quoted 2 lines
target-lm32/translate.c new file +2
-0+tcg_gen_xor_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +tcg_gen_not_tl (cpu_R[dc->r2], cpu_R[dc->r2]);
This is tcg_gen_eqv_tl.
target-lm32/translate.c line 1086
Quoted 8 lines
target-lm32/translate.c new file +8
-0+/* Large switch for all insns. */ +for (i =0 ; i <ARRAY_SIZE (decinfo); i++) { +if ((dc->opcode & decinfo[i].mask) == decinfo[i].bits) { + decinfo[i].dec (dc); +break ; + } + } +}
No check that *some* opcode matched? It would seem like a "return" here instead of a break, and then an illegal opcode exception after the loop would be in order.
r~
Re: [Qemu-devel] [PATCH 02/17] lm32: translation routines
Quoted 12 lines · Richard Henderson
target-lm32/translate.c line 359
Quoted 10 lines · Michael Walle
target-lm32/translate.c new file +10
-0+if (dc->format ==OP_FMT_RI ) { +tcg_gen_brcondi_tl (cond, cpu_R[rY],sign_extend (dc->imm16,16 ), l1); + }else { +tcg_gen_brcond_tl (cond, cpu_R[rY], cpu_R[rZ], l1); + } +tcg_gen_movi_tl (cpu_R[rX],0 ); +tcg_gen_br (l2); +gen_set_label (l1); +tcg_gen_movi_tl (cpu_R[rX],1 ); +gen_set_label (l2);
Quoted 4 lines
This is
tcg_gen_setcond_tl.BTW, why the extensive extra
LOG_DIScode? Why not just run the regular disassembler, like other ports?
FWIW, I used the same macros in the CRIS & MicroBlaze translators because I found using the translators decoding useful to compare with the regular disassembler's when looking for decoding errors. Also, some times I used the translators disasm because it is faster (it doesn't have to decode the insns twice), although not as readable. It was a while ago though...
Quoted 20 lines
target-lm32/translate.c line 541
Quoted 3 lines
target-lm32/translate.c new file +3
-0+if (!(dc->env->features &LM32_FEATURE_MULTIPLY )) { +cpu_abort (dc->env,"hardware multiplier is not available\n" ); + }Aborting the VM, rather than raising an exception?
target-lm32/translate.c line 962
Quoted 2 lines
target-lm32/translate.c new file +2
-0+tcg_gen_xor_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +tcg_gen_not_tl (cpu_R[dc->r2], cpu_R[dc->r2]);This is
tcg_gen_eqv_tl.target-lm32/translate.c line 1086
Quoted 8 lines
target-lm32/translate.c new file +8
-0+/* Large switch for all insns. */ +for (i =0 ; i <ARRAY_SIZE (decinfo); i++) { +if ((dc->opcode & decinfo[i].mask) == decinfo[i].bits) { + decinfo[i].dec (dc); +break ; + } + } +}
Quoted 3 lines
No check that *some* opcode matched? It would seem like a "return" here instead of a break, and then an illegal opcode exception after the loop would be in order.
Good catch!
Other ports using the same decoding approach have a "match all" entry in the decinfo table to catch illegal insns..
Cheers
Re: [Qemu-devel] [PATCH 02/17] lm32: translation routines
In reply to Richard HendersonAm Dienstag 08 Februar 2011, 18:32:57 schrieb Richard Henderson:
Quoted 12 lines · Michael Walle
target-lm32/translate.c line 359
Quoted 10 lines
(quoted diff) +2
-0+ if (dc->format == OP_FMT_RI) { + tcg_gen_brcondi_tl(cond, cpu_R[rY], sign_extend(dc->imm16, 16),l1); + } else {
target-lm32/translate.c new file +7
-0+tcg_gen_brcond_tl (cond, cpu_R[rY], cpu_R[rZ], l1); + } +tcg_gen_movi_tl (cpu_R[rX],0 ); +tcg_gen_br (l2); +gen_set_label (l1); +tcg_gen_movi_tl (cpu_R[rX],1 ); +gen_set_label (l2);
Quoted 1 line
This is
tcg_gen_setcond_tl.
fixed, thanks
Quoted 2 lines
BTW, why the extensive extra
LOG_DIScode? Why not just run the regular disassembler, like other ports?
There is no built in disassembler for qemu (yet). The lm32 binutils port uses cgen for parsing, so the lm32-dis.c is not self contained. Either i need to embed cgen into the lm32-dis.c, write my own disassembler or qemu needs to link again libopcodes). I didn't like any of these solutions :)
Quoted 5 lines
target-lm32/translate.c line 541
Quoted 3 lines
target-lm32/translate.c new file +3
-0+if (!(dc->env->features &LM32_FEATURE_MULTIPLY )) { +cpu_abort (dc->env,"hardware multiplier is not available\n" ); + }Aborting the VM, rather than raising an exception?
The LM32 processor does not raise an exception in that case. If there is an unknown opcode its behaviour is undefined on real hardware.
Quoted 5 lines
target-lm32/translate.c line 962
Quoted 3 lines
target-lm32/translate.c new file +2
-0+tcg_gen_xor_tl (cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); +tcg_gen_not_tl (cpu_R[dc->r2], cpu_R[dc->r2]);This is
tcg_gen_eqv_tl.
fixed too, unfortunately there is no variant with an immediate.
Quoted 9 lines
target-lm32/translate.c line 1086
Quoted 8 lines
target-lm32/translate.c new file +8
-0+/* Large switch for all insns. */ +for (i =0 ; i <ARRAY_SIZE (decinfo); i++) { +if ((dc->opcode & decinfo[i].mask) == decinfo[i].bits) { + decinfo[i].dec (dc); +break ; + } + } +}
Quoted 3 lines
No check that *some* opcode matched? It would seem like a "return" here instead of a break, and then an illegal opcode exception after the loop would be in order.
fixed too. Again, if there is no match, the VM will be killed.
Signature · 1 line
thanks michael
PATCH 3/17 lm32: translation code helper
In reply to Michael WalleThis patch adds translation helper functions.
--- target-lm32/helper.h | 14 ++++++ target-lm32/op_helper.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 0 deletions(-) create mode 100644 target-lm32/helper.h create mode 100644 target-lm32/op_helper.c
target-lm32/helper.h new file +14 -0
@@ -0,0 +1,14 @@ +#include "def-helper.h" + +DEF_HELPER_1(raise_exception, void, i32) +DEF_HELPER_0(hlt, void) +DEF_HELPER_1(wcsr_im, void, i32) +DEF_HELPER_1(wcsr_ip, void, i32) +DEF_HELPER_1(wcsr_jtx, void, i32) +DEF_HELPER_1(wcsr_jrx, void, i32) +DEF_HELPER_0(rcsr_im, i32) +DEF_HELPER_0(rcsr_ip, i32) +DEF_HELPER_0(rcsr_jtx, i32) +DEF_HELPER_0(rcsr_jrx, i32) + +#include "def-helper.h"
target-lm32/op_helper.c new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 4/17 lm32: machine state loading/saving
In reply to Michael WalleThis patch adds support for saving and loading the processor state.
--- target-lm32/machine.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) create mode 100644 target-lm32/machine.c
target-lm32/machine.c new file +33 -0
@@ -0,0 +1,33 @@ +#include "hw/hw.h" +#include "hw/boards.h" + +static const VMStateDescription vmstate_cpu = { + .name ="cpu" , + .version_id =CPU_SAVE_VERSION , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, CPUState,32 ), +VMSTATE_UINT32 (pc, CPUState), +VMSTATE_UINT32 (ie, CPUState), +VMSTATE_UINT32 (icc, CPUState), +VMSTATE_UINT32 (dcc, CPUState), +VMSTATE_UINT32 (cc, CPUState), +VMSTATE_UINT32 (eba, CPUState), +VMSTATE_UINT32 (dc, CPUState), +VMSTATE_UINT32 (deba, CPUState), +VMSTATE_UINT32_ARRAY (bp, CPUState,4 ), +VMSTATE_UINT32_ARRAY (wp, CPUState,4 ), +VMSTATE_END_OF_LIST () + } +}; + +void cpu_save (QEMUFile *f,void *opaque) +{ +vmstate_save_state (f, &vmstate_cpu, opaque); +} + +int cpu_load (QEMUFile *f,void *opaque,int version_id) +{ +return vmstate_load_state (f, &vmstate_cpu, opaque, version_id); +}
Signature · 1 line
1.7.2.3
PATCH 5/17 lm32: gdbstub support
In reply to Michael WalleThis patch adds lm32 support to the gdbstub.
--- gdbstub.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-)
gdbstub.c +76 -0
@@ -1462,6 +1462,80 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)return r; } +#elif defined (TARGET_LM32 ) + +#include "hw/lm32_pic.h" +#define NUM_CORE_REGS (32 + 7) + +static int cpu_gdb_read_register (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +GET_REG32 (env->regs[n]); + }else { +switch (n) { +case 32 : +GET_REG32 (env->pc); +break ; +/* FIXME: put in right exception ID */ +case 33 : +GET_REG32 (0 ); +break ; +case 34 : +GET_REG32 (env->eba); +break ; +case 35 : +GET_REG32 (env->deba); +break ; +case 36 : +GET_REG32 (env->ie); +break ; +case 37 : +GET_REG32 (lm32_pic_get_im (env)); +break ; +case 38 : +GET_REG32 (lm32_pic_get_ip (env)); +break ; + } + } +return 0 ; +} + +static int cpu_gdb_write_register (CPUState *env,uint8_t *mem_buf,int n) +{ +uint32_t tmp; + +if (n >NUM_CORE_REGS ) { +return 0 ; + } + + tmp =ldl_p (mem_buf); + +if (n <32 ) { + env->regs[n] = tmp; + }else { +switch (n) { +case 32 : + env->pc = tmp; +break ; +case 34 : + env->eba = tmp; +break ; +case 35 : + env->deba = tmp; +break ; +case 36 : + env->ie = tmp; +break ; +case 37 : +lm32_pic_set_im (env, tmp); +break ; +case 38 : +lm32_pic_set_ip (env, tmp); +break ; + } + } +return 4 ; +}#else #define NUM_CORE_REGS 0
@@ -1737,6 +1811,8 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)#elif defined (TARGET_S390X )cpu_synchronize_state (s->c_cpu); s->c_cpu->psw.addr = pc; +#elif defined (TARGET_LM32 ) + s->c_cpu->pc = pc;#endif }
Signature · 1 line
1.7.2.3
PATCH 6/17 lm32: interrupt controller model
In reply to Michael WalleThis patch adds the interrupt controller of the lm32. Because the PIC is accessed through special control registers and opcodes, there are callbacks from the lm32 translation code to this model.
--- hw/lm32_pic.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/lm32_pic.h | 10 +++ hw/lm32_pic_cpu.c | 37 ++++++++++ trace-events | 9 +++ 4 files changed, 247 insertions(+), 0 deletions(-) create mode 100644 hw/lm32_pic.c create mode 100644 hw/lm32_pic.h create mode 100644 hw/lm32_pic_cpu.c
hw/lm32_pic.c new file +191 -0
@@ -0,0 +1,191 @@ +/* +* LatticeMico32 CPU interrupt controller logic. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +#include <assert.h> + +#include "hw.h" +#include "pc.h" +#include "monitor.h" +#include "sysbus.h" +#include "trace.h" +#include "lm32_pic.h" + +struct LM32PicState { +SysBusDevice busdev; +qemu_irq parent_irq; +uint32_t im;/* interrupt mask */ +uint32_t ip;/* interrupt pending */ +uint32_t irq_state; + +/* statistics */ +uint32_t stats_irq_count[32 ]; +}; +typedef struct LM32PicState LM32PicState ; + +static LM32PicState *pic; +void pic_info (Monitor *mon) +{ +if (pic ==NULL ) { +return ; + } + +monitor_printf (mon,"lm32-pic: im=%08x ip=%08x irq_state=%08x\n" , + pic->im, pic->ip, pic->irq_state); +} + +void irq_info (Monitor *mon) +{ +int i; +uint32_t count; + +if (pic ==NULL ) { +return ; + } + +monitor_printf (mon,"IRQ statistics:\n" ); +for (i =0 ; i <32 ; i++) { + count = pic->stats_irq_count[i]; +if (count >0 ) { +monitor_printf (mon,"%2d: %u\n" , i, count); + } + } +} + +static void update_irq (LM32PicState *s) +{ + s->ip |= s->irq_state; + +if (s->ip & s->im) { +trace_lm32_pic_raise_irq (); +qemu_irq_raise (s->parent_irq); + }else { +trace_lm32_pic_lower_irq (); +qemu_irq_lower (s->parent_irq); + } +} + +static void irq_handler (void *opaque,int irq,int level) +{ +LM32PicState *s = opaque; + +assert (irq <32 ); +trace_lm32_pic_interrupt (irq, level); + +if (level) { + s->irq_state |= (1 << irq); + s->stats_irq_count[irq]++; + }else { + s->irq_state &= ~(1 << irq); + } + +update_irq (s); +} + +void lm32_pic_set_im (CPUState *env,uint32_t im) +{ +LM32PicState *s = env->pic_env; + +trace_lm32_pic_set_im (im); + s->im = im; + +update_irq (s); +} + +void lm32_pic_set_ip (CPUState *env,uint32_t ip) +{ +LM32PicState *s = env->pic_env; + +trace_lm32_pic_set_ip (ip); + +/* ack interrupt */ + s->ip &= ~ip; + +update_irq (s); +} + +uint32_t lm32_pic_get_im (CPUState *env) +{ +LM32PicState *s = env->pic_env; + +trace_lm32_pic_get_im (s->im); +return s->im; +} + +uint32_t lm32_pic_get_ip (CPUState *env) +{ +LM32PicState *s = env->pic_env; + +trace_lm32_pic_get_ip (s->ip); +return s->ip; +} + +static void pic_reset (void *opaque) +{ +LM32PicState *s = opaque; +int i; + + s->im =0 ; + s->ip =0 ; + s->irq_state =0 ; +for (i =0 ; i <32 ; i++) { + s->stats_irq_count[i] =0 ; + } +qemu_irq_lower (s->parent_irq); +} + +static int lm32_pic_init (SysBusDevice *dev) +{ +LM32PicState *s =FROM_SYSBUS (typeof (*s), dev); + +qdev_init_gpio_in (&dev->qdev, irq_handler,32 ); +sysbus_init_irq (dev, &s->parent_irq); +qemu_register_reset (pic_reset, s); + + pic = s; + +return 0 ; +} + +static const VMStateDescription vmstate_lm32_pic = { + .name ="lm32-pic" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (im, LM32PicState), +VMSTATE_UINT32 (ip, LM32PicState), +VMSTATE_UINT32 (irq_state, LM32PicState), +VMSTATE_UINT32_ARRAY (stats_irq_count, LM32PicState,32 ), +VMSTATE_END_OF_LIST () + } +}; + +static SysBusDeviceInfo lm32_pic_info = { + .init = lm32_pic_init, + .qdev.name ="lm32-pic" , + .qdev.size =sizeof (LM32PicState), + .qdev.vmsd = &vmstate_lm32_pic, +}; + +static void lm32_pic_register (void ) +{ +sysbus_register_withprop (&lm32_pic_info); +} + +device_init (lm32_pic_register)
hw/lm32_pic.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef __LM32_PIC +#define __LM32_PIC + +#include "qemu-common.h" + +uint32_t lm32_pic_get_ip (CPUState *env); +uint32_t lm32_pic_get_im (CPUState *env); +void lm32_pic_set_ip (CPUState *env,uint32_t ip); +void lm32_pic_set_im (CPUState *env,uint32_t im); +#endif
hw/lm32_pic_cpu.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* LatticeMico32 CPU interrupt wrapper logic. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +#include "hw.h" + +static void lm32_pic_cpu_handler (void *opaque,int irq,int level) +{ +CPUState *env = (CPUState *)opaque; + +if (level) { +cpu_interrupt (env,CPU_INTERRUPT_HARD ); + }else { +cpu_reset_interrupt (env,CPU_INTERRUPT_HARD ); + } +} + +qemu_irq *lm32_pic_init_cpu (CPUState *env); +qemu_irq *lm32_pic_init_cpu (CPUState *env) +{ +return qemu_allocate_irqs (lm32_pic_cpu_handler, env,1 ); +}
trace-events +9 -0
@@ -213,3 +213,12 @@ disable qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t disable qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64"" disable qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64"" disable qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" + +# hw/lm32_pic.c +disable lm32_pic_raise_irq(void) "Raise CPU interrupt" +disable lm32_pic_lower_irq(void) "Lower CPU interrupt" +disable lm32_pic_interrupt(int irq, int level) "Set IRQ%d %d" +disable lm32_pic_set_im(uint32_t im) "im=%08x" +disable lm32_pic_set_ip(uint32_t ip) "ip=%08x" +disable lm32_pic_get_im(uint32_t im) "im=%08x" +disable lm32_pic_get_ip(uint32_t ip) "ip=%08x"
Signature · 1 line
1.7.2.3
PATCH 7/17 lm32: juart model
In reply to Michael WalleThis patch adds the JTAG UART model. It is accessed through special control registers and opcodes. Therefore the translation uses callbacks to this model.
--- hw/lm32_juart.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/lm32_juart.h | 10 ++++ trace-events | 6 ++ 3 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 hw/lm32_juart.c create mode 100644 hw/lm32_juart.h
hw/lm32_juart.c new file +151 -0
@@ -0,0 +1,151 @@ +/* +* LatticeMico32 JTAG UART model. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +#include "hw.h" +#include "sysbus.h" +#include "trace.h" +#include "qemu-char.h" + +#include "lm32_juart.h" + +enum { +LM32_JUART_MIN_SAVE_VERSION =0 , +LM32_JUART_CURRENT_SAVE_VERSION =0 , +LM32_JUART_MAX_SAVE_VERSION =0 , +}; + +enum { +JTX_FULL = (1 <<8 ), +}; + +enum { +JRX_FULL = (1 <<8 ), +}; + +struct LM32JuartState { +SysBusDevice busdev; +CharDriverState *chr; + +uint32_t jtx; +uint32_t jrx; +}; +typedef struct LM32JuartState LM32JuartState ; + +uint32_t lm32_juart_get_jtx (CPUState *env) +{ +LM32JuartState *s = env->juart_env; + +trace_lm32_juart_get_jtx (s->jtx); +return s->jtx; +} + +uint32_t lm32_juart_get_jrx (CPUState *env) +{ +LM32JuartState *s = env->juart_env; + +trace_lm32_juart_get_jrx (s->jrx); +return s->jrx; +} + +void lm32_juart_set_jtx (CPUState *env,uint32_t jtx) +{ +LM32JuartState *s = env->juart_env; +unsigned char ch = jtx &0xff ; + +trace_lm32_juart_set_jtx (s->jtx); + + s->jtx = jtx; +if (s->chr) { +qemu_chr_write (s->chr, &ch,1 ); + } +} + +void lm32_juart_set_jrx (CPUState *env,uint32_t jtx) +{ +LM32JuartState *s = env->juart_env; + +trace_lm32_juart_set_jrx (s->jrx); + env->juart_env->jrx &= ~JRX_FULL ; +} + +static void juart_rx (void *opaque,const uint8_t *buf,int size) +{ +LM32JuartState *s = opaque; + + s->jrx = *buf |JRX_FULL ; +} + +static int juart_can_rx (void *opaque) +{ +LM32JuartState *s = opaque; + +return !(s->jrx &JRX_FULL ); +} + +static void juart_event (void *opaque,int event) +{ +} + +static void juart_reset (void *opaque) +{ +LM32JuartState *s = opaque; + + s->jtx =0 ; + s->jrx =0 ; +} + +static int lm32_juart_init (SysBusDevice *dev) +{ +LM32JuartState *s =FROM_SYSBUS (typeof (*s), dev); + + s->chr =qdev_init_chardev (&dev->qdev); +if (s->chr) { +qemu_chr_add_handlers (s->chr, juart_can_rx, juart_rx, juart_event, s); + } + +qemu_register_reset (juart_reset, s); + +return 0 ; +} + +static const VMStateDescription vmstate_lm32_juart = { + .name ="lm32-juart" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (jtx, LM32JuartState), +VMSTATE_UINT32 (jrx, LM32JuartState), +VMSTATE_END_OF_LIST () + } +}; + +static SysBusDeviceInfo lm32_juart_info = { + .init = lm32_juart_init, + .qdev.name ="lm32-juart" , + .qdev.size =sizeof (LM32JuartState), + .qdev.vmsd = &vmstate_lm32_juart, +}; + +static void lm32_juart_register (void ) +{ +sysbus_register_withprop (&lm32_juart_info); +} + +device_init (lm32_juart_register)
hw/lm32_juart.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef __LM32_JUART +#define __LM32_JUART + +#include "qemu-common.h" + +uint32_t lm32_juart_get_jtx (CPUState *env); +uint32_t lm32_juart_get_jrx (CPUState *env); +void lm32_juart_set_jtx (CPUState *env,uint32_t jtx); +void lm32_juart_set_jrx (CPUState *env,uint32_t jrx); +#endif
trace-events +6 -0
@@ -222,3 +222,9 @@ disable lm32_pic_set_im(uint32_t im) "im=%08x" disable lm32_pic_set_ip(uint32_t ip) "ip=%08x" disable lm32_pic_get_im(uint32_t im) "im=%08x" disable lm32_pic_get_ip(uint32_t ip) "ip=%08x" + +# hw/lm32_juart.c +disable lm32_juart_get_jtx(uint32_t value) "value=%08x" +disable lm32_juart_set_jtx(uint32_t value) "value=%08x" +disable lm32_juart_get_jrx(uint32_t value) "value=%08x" +disable lm32_juart_set_jrx(uint32_t value) "value=%08x"
Signature · 1 line
1.7.2.3
PATCH 8/17 lm32: pic and juart helper functions
In reply to Michael WalleThis patch adds init functions for the PIC and JTAG UART commonly used in the board initialization.
--- hw/lm32.h | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) create mode 100644 hw/lm32.h
hw/lm32.h new file +31 -0
@@ -0,0 +1,31 @@ + +#include "qemu-common.h" + +static inline DeviceState *lm32_pic_init (CPUState *env,qemu_irq cpu_irq) +{ +DeviceState *dev; +SysBusDevice *d; + + dev =qdev_create (NULL ,"lm32-pic" ); +qdev_init_nofail (dev); + d =sysbus_from_qdev (dev); +sysbus_connect_irq (d,0 , cpu_irq); + + env->pic_env = (struct LM32PicState *)dev; + +return dev; +} + +static inline DeviceState *lm32_juart_init (CPUState *env) +{ +DeviceState *dev; +SysBusDevice *d; + + dev =qdev_create (NULL ,"lm32-juart" ); +qdev_init_nofail (dev); + d =sysbus_from_qdev (dev); + + env->juart_env = (struct LM32JuartState *)dev; + +return dev; +}
Signature · 1 line
1.7.2.3
PATCH 9/17 lm32: timer model
In reply to Michael WalleThis patch adds support for the LatticeMico32 system timer.
--- Makefile.target | 1 + hw/lm32_timer.c | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 6 ++ 3 files changed, 234 insertions(+), 0 deletions(-) create mode 100644 hw/lm32_timer.c
Makefile.target +1 -0
@@ -251,6 +251,7 @@ obj-ppc-y += xilinx_ethlite.o obj-lm32-y += lm32_pic.o obj-lm32-y += lm32_pic_cpu.o obj-lm32-y += lm32_juart.o +obj-lm32-y += lm32_timer.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/lm32_timer.c new file +227 -0
227 lines not on this page · raw message
trace-events +6 -0
@@ -228,3 +228,9 @@ disable lm32_juart_get_jtx(uint32_t value) "value=%08x" disable lm32_juart_set_jtx(uint32_t value) "value=%08x" disable lm32_juart_get_jrx(uint32_t value) "value=%08x" disable lm32_juart_set_jrx(uint32_t value) "value=%08x" + +# hw/lm32_timer.c +disable lm32_timer_memory_write(uint32_t addr, uint32_t value) "addr=%08x value=%08x" +disable lm32_timer_memory_read(uint32_t addr, uint32_t value) "addr=%08x value=%08x" +disable lm32_timer_hit(void) "Timer hit" +disable lm32_timer_irq_state(int level) "Timer IRQ state %d"
Signature · 1 line
1.7.2.3
PATCH 10/17 lm32: uart model
In reply to Michael WalleThis patch add support for the LatticeMico32 UART.
--- Makefile.target | 1 + hw/lm32_uart.c | 292 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 5 + 3 files changed, 298 insertions(+), 0 deletions(-) create mode 100644 hw/lm32_uart.c
Makefile.target +1 -0
@@ -252,6 +252,7 @@ obj-lm32-y += lm32_pic.o obj-lm32-y += lm32_pic_cpu.o obj-lm32-y += lm32_juart.o obj-lm32-y += lm32_timer.o +obj-lm32-y += lm32_uart.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/lm32_uart.c new file +292 -0
292 lines not on this page · raw message
trace-events +5 -0
@@ -234,3 +234,8 @@ disable lm32_timer_memory_write(uint32_t addr, uint32_t value) "addr=%08x value= disable lm32_timer_memory_read(uint32_t addr, uint32_t value) "addr=%08x value=%08x" disable lm32_timer_hit(void) "Timer hit" disable lm32_timer_irq_state(int level) "Timer IRQ state %d" + +# hw/lm32_uart.c +disable lm32_uart_memory_write(uint32_t addr, uint32_t value) "addr=%08x value=%08x" +disable lm32_uart_memory_read(uint32_t addr, uint32_t value) "addr=%08x value=%08x" +disable lm32_uart_irq_state(int level) "UART IRQ state %d"
Signature · 1 line
1.7.2.3
PATCH 11/17 lm32: system control model
In reply to Michael WalleThis patch add support for a system control block. It is supposed to act as helper for the emulated program. E.g. shutting down the VM or printing test results. This model is intended for testing purposes only and doesn't fit to any real hardware. Therefore, it is not added to any board by default. Instead a user has to add it explicitly with the '-device' commandline parameter.
--- Makefile.target | 1 + hw/lm32_sys.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 3 + 3 files changed, 160 insertions(+), 0 deletions(-) create mode 100644 hw/lm32_sys.c
Makefile.target +1 -0
@@ -253,6 +253,7 @@ obj-lm32-y += lm32_pic_cpu.o obj-lm32-y += lm32_juart.o obj-lm32-y += lm32_timer.o obj-lm32-y += lm32_uart.o +obj-lm32-y += lm32_sys.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/lm32_sys.c new file +156 -0
156 lines not on this page · raw message
trace-events +3 -0
@@ -239,3 +239,6 @@ disable lm32_timer_irq_state(int level) "Timer IRQ state %d" disable lm32_uart_memory_write(uint32_t addr, uint32_t value) "addr=%08x value=%08x" disable lm32_uart_memory_read(uint32_t addr, uint32_t value) "addr=%08x value=%08x" disable lm32_uart_irq_state(int level) "UART IRQ state %d" + +# hw/lm32_sys.c +disable lm32_sys_memory_write(uint32_t addr, uint32_t value) "addr=%08x value=%08x"
Signature · 1 line
1.7.2.3
PATCH 12/17 lm32: support for creating device tree
In reply to Michael WalleThis patch adds helper functions to create a ROM, which contains a hardware description of a board. This is used in Theobromas LM32 Linux port.
--- hw/lm32_hwsetup.h | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 172 insertions(+), 0 deletions(-) create mode 100644 hw/lm32_hwsetup.h
hw/lm32_hwsetup.h new file +172 -0
@@ -0,0 +1,172 @@ +/* +* LatticeMico32 hwsetup helper functions. +* +* Copyright (c) 2010 Michael Walle <[email protected]> +* +* 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 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/>. +*/ + +/* +* These are helper functions for creating the hardware description blob used +* in the Theobroma's uClinux port. +*/ + +#include "qemu-common.h" +#include "loader.h" + +struct hwsetup { +void *data; +void *ptr; +}; + +enum hwsetup_tag { +HWSETUP_TAG_EOL =0 , +HWSETUP_TAG_CPU =1 , +HWSETUP_TAG_ASRAM =2 , +HWSETUP_TAG_FLASH =3 , +HWSETUP_TAG_SDRAM =4 , +HWSETUP_TAG_OCM =5 , +HWSETUP_TAG_DDR_SDRAM =6 , +HWSETUP_TAG_DDR2_SDRAM =7 , +HWSETUP_TAG_TIMER =8 , +HWSETUP_TAG_UART =9 , +HWSETUP_TAG_GPIO =10 , +HWSETUP_TAG_TRISPEEDMAC =11 , +HWSETUP_TAG_I2CM =12 , +HWSETUP_TAG_LEDS =13 , +HWSETUP_TAG_7SEG =14 , +HWSETUP_TAG_SPI_S =15 , +HWSETUP_TAG_SPI_M =16 , +}; + +static inline struct hwsetup *hwsetup_init (void ) +{ +struct hwsetup *hw; + + hw =qemu_malloc (sizeof (struct hwsetup )); + hw->data =qemu_mallocz (TARGET_PAGE_SIZE ); + hw->ptr = hw->data; + +return hw; +} + +static inline void hwsetup_free (struct hwsetup *hw) +{ +qemu_free (hw->data); +qemu_free (hw); +} + +static inline void hwsetup_create_rom (struct hwsetup *hw,ram_addr_t base) +{ +rom_add_blob ("hwsetup" , hw->data,TARGET_PAGE_SIZE , base); +} + +static inline void hwsetup_add_u8 (struct hwsetup *hw,uint8_t u) +{ +stb_p (hw->ptr, u); + hw->ptr +=1 ; +} + +static inline void hwsetup_add_u32 (struct hwsetup *hw,uint32_t u) +{ +stl_p (hw->ptr, u); + hw->ptr +=4 ; +} + +static inline void hwsetup_add_tag (struct hwsetup *hw,enum hwsetup_tag t) +{ +stl_p (hw->ptr, t); + hw->ptr +=4 ; +} + +static inline void hwsetup_add_str (struct hwsetup *hw,const char *str) +{ +strncpy (hw->ptr, str,31 );/* make sure last byte is zero */ + hw->ptr +=32 ; +} + +static inline void hwsetup_add_trailer (struct hwsetup *hw) +{ +hwsetup_add_u32 (hw,8 );/* size */ +hwsetup_add_tag (hw,HWSETUP_TAG_EOL ); +} + +static inline void hwsetup_add_cpu (struct hwsetup *hw, +const char *name,uint32_t frequency) +{ +hwsetup_add_u32 (hw,44 );/* size */ +hwsetup_add_tag (hw,HWSETUP_TAG_CPU ); +hwsetup_add_str (hw, name); +hwsetup_add_u32 (hw, frequency); +} + +static inline void hwsetup_add_flash (struct hwsetup *hw, +const char *name,uint32_t base,uint32_t size) +{ +hwsetup_add_u32 (hw,52 );/* size */ +hwsetup_add_tag (hw,HWSETUP_TAG_FLASH ); +hwsetup_add_str (hw, name); +hwsetup_add_u32 (hw, base); +hwsetup_add_u32 (hw, size); +hwsetup_add_u8 (hw,8 );/* read latency */ +hwsetup_add_u8 (hw,8 );/* write latency */ +hwsetup_add_u8 (hw,25 );/* address width */ +hwsetup_add_u8 (hw,32 );/* data width */ +} + +static inline void hwsetup_add_ddr_sdram (struct hwsetup *hw, +const char *name,uint32_t base,uint32_t size) +{ +hwsetup_add_u32 (hw,48 );/* size */ +hwsetup_add_tag (hw,HWSETUP_TAG_DDR_SDRAM ); +hwsetup_add_str (hw, name); +hwsetup_add_u32 (hw, base); +hwsetup_add_u32 (hw, size); +} + +static inline void hwsetup_add_timer (struct hwsetup *hw, +const char *name,uint32_t base,uint32_t irq) +{ +hwsetup_add_u32 (hw,56 );/* size */ +hwsetup_add_tag (hw,HWSETUP_TAG_TIMER ); +hwsetup_add_str (hw, name); +hwsetup_add_u32 (hw, base); +hwsetup_add_u8 (hw,1 );/* wr_tickcount */ +hwsetup_add_u8 (hw,1 );/* rd_tickcount */ +hwsetup_add_u8 (hw,1 );/* start_stop_control */ +hwsetup_add_u8 (hw,32 );/* counter_width */ +hwsetup_add_u32 (hw,20 );/* reload_ticks */ +hwsetup_add_u8 (hw, irq); +hwsetup_add_u8 (hw,0 );/* padding */ +hwsetup_add_u8 (hw,0 );/* padding */ +hwsetup_add_u8 (hw,0 );/* padding */ +} + +static inline void hwsetup_add_uart (struct hwsetup *hw, +const char *name,uint32_t base,uint32_t irq) +{ +hwsetup_add_u32 (hw,56 );/* size */ +hwsetup_add_tag (hw,HWSETUP_TAG_UART ); +hwsetup_add_str (hw, name); +hwsetup_add_u32 (hw, base); +hwsetup_add_u32 (hw,115200 );/* baudrate */ +hwsetup_add_u8 (hw,8 );/* databits */ +hwsetup_add_u8 (hw,1 );/* stopbits */ +hwsetup_add_u8 (hw,1 );/* use_interrupt */ +hwsetup_add_u8 (hw,1 );/* block_on_transmit */ +hwsetup_add_u8 (hw,1 );/* block_on_receive */ +hwsetup_add_u8 (hw,4 );/* rx_buffer_size */ +hwsetup_add_u8 (hw,4 );/* tx_buffer_size */ +hwsetup_add_u8 (hw, irq); +}
Signature · 1 line
1.7.2.3
PATCH 13/17 lm32: EVR32 and uclinux BSP
In reply to Michael WalleThis patch adds support for the following two BSPs:
- LM32 EVR32 BSP (as used by RTEMS)
- uclinux BSP by Theobroma Systems
--- Makefile.target | 3 + default-configs/lm32-softmmu.mak | 4 + hw/lm32_boards.c | 295 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 302 insertions(+), 0 deletions(-) create mode 100644 default-configs/lm32-softmmu.mak create mode 100644 hw/lm32_boards.c
Makefile.target +3 -0
@@ -247,6 +247,9 @@ obj-ppc-y += xilinx_timer.o obj-ppc-y += xilinx_uartlite.o obj-ppc-y += xilinx_ethlite.o +# LM32 boards +obj-lm32-y += lm32_boards.o + # LM32 peripherals obj-lm32-y += lm32_pic.o obj-lm32-y += lm32_pic_cpu.o
default-configs/lm32-softmmu.mak new file +4 -0
@@ -0,0 +1,4 @@ +# Default configuration for lm32-softmmu + +CONFIG_PTIMER=y +CONFIG_PFLASH_CFI02=y
hw/lm32_boards.c new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 14/17 lm32: todo and documentation
In reply to Michael WalleThis patch adds general target documentation and a todo list.
--- target-lm32/README | 46 ++++++++++++++++++++++++++++++++++++++++++++++ target-lm32/TODO | 3 +++ 2 files changed, 49 insertions(+), 0 deletions(-) create mode 100644 target-lm32/README create mode 100644 target-lm32/TODO
target-lm32/README new file +46 -0
@@ -0,0 +1,46 @@ +LatticeMico32 target +-------------------- + +General +------- +All opcodes including the JUART CSRs are supported. + + +JTAG UART +--------- +JTAG UART is routed to a serial console device. For the current boards it +is the second one. Ie to enable it in the qemu virtual console window use +the following command line parameters: + -serial vc -serial vc +This will make serial0 (the lm32_uart) and serial1 (the JTAG UART) +available as virtual consoles. + + +Programmatically terminate the emulator +---------------------------------------- +Originally neither the LatticeMico32 nor its peripherals support a +mechanism to shut down the machine. Emulation aware programs can write to a +to a special register within the system control block to shut down the +virtual machine. For more details see hw/lm32_sys.c. The lm32-evr is the +first BSP which instantiate this model. A (32 bit) write to 0xfff0000 +causes a vm shutdown. + + +Special instructions +-------------------- +The translation recognizes one special instruction to halt the cpu: + and r0, r0, r0 +On real hardware this instruction is a nop. It is not used by GCC and +should (hopefully) not be used within hand-crafted assembly. +Insert this instruction in your idle loop to reduce the cpu load on the +host. + + +Ignoring the MSB of the address bus +----------------------------------- +Some SoC ignores the MSB on the address bus. Thus creating a shadow memory +area. As a general rule, 0x00000000-0x7fffffff is cached, whereas +0x80000000-0xffffffff is not cached and used to access IO devices. This +behaviour can be enabled with: + cpu_lm32_set_phys_msb_ignore(env, 1); +
target-lm32/TODO new file +3 -0
@@ -0,0 +1,3 @@ +* disassembler (lm32-dis.c) +* linux-user emulation +* native bp/wp emulation (?)
Signature · 1 line
1.7.2.3
PATCH 15/17 lm32: opcode testsuite
In reply to Michael WalleThis patch creates tests/lm32 directory and adds tests for every LatticeMico32 opcode.
--- tests/Makefile | 4 ++ tests/lm32/Makefile | 102 +++++++++++++++++++++++++++++++++++++++++++++ tests/lm32/crt.S | 84 +++++++++++++++++++++++++++++++++++++ tests/lm32/linker.ld | 55 ++++++++++++++++++++++++ tests/lm32/macros.inc | 79 ++++++++++++++++++++++++++++++++++ tests/lm32/test_add.S | 75 +++++++++++++++++++++++++++++++++ tests/lm32/test_addi.S | 56 ++++++++++++++++++++++++ tests/lm32/test_and.S | 45 ++++++++++++++++++++ tests/lm32/test_andhi.S | 35 +++++++++++++++ tests/lm32/test_andi.S | 35 +++++++++++++++ tests/lm32/test_b.S | 13 ++++++ tests/lm32/test_be.S | 48 +++++++++++++++++++++ tests/lm32/test_bg.S | 78 ++++++++++++++++++++++++++++++++++ tests/lm32/test_bge.S | 78 ++++++++++++++++++++++++++++++++++ tests/lm32/test_bgeu.S | 78 ++++++++++++++++++++++++++++++++++ tests/lm32/test_bgu.S | 78 ++++++++++++++++++++++++++++++++++ tests/lm32/test_bi.S | 23 ++++++++++ tests/lm32/test_bne.S | 48 +++++++++++++++++++++ tests/lm32/test_break.S | 20 +++++++++ tests/lm32/test_bret.S | 38 +++++++++++++++++ tests/lm32/test_call.S | 16 +++++++ tests/lm32/test_calli.S | 15 +++++++ tests/lm32/test_cmpe.S | 40 +++++++++++++++++ tests/lm32/test_cmpei.S | 35 +++++++++++++++ tests/lm32/test_cmpg.S | 64 ++++++++++++++++++++++++++++ tests/lm32/test_cmpge.S | 64 ++++++++++++++++++++++++++++ tests/lm32/test_cmpgei.S | 55 ++++++++++++++++++++++++ tests/lm32/test_cmpgeu.S | 64 ++++++++++++++++++++++++++++ tests/lm32/test_cmpgeui.S | 55 ++++++++++++++++++++++++ tests/lm32/test_cmpgi.S | 55 ++++++++++++++++++++++++ tests/lm32/test_cmpgu.S | 64 ++++++++++++++++++++++++++++ tests/lm32/test_cmpgui.S | 55 ++++++++++++++++++++++++ tests/lm32/test_cmpne.S | 40 +++++++++++++++++ tests/lm32/test_cmpnei.S | 35 +++++++++++++++ tests/lm32/test_divu.S | 29 +++++++++++++ tests/lm32/test_eret.S | 38 +++++++++++++++++ tests/lm32/test_lb.S | 45 ++++++++++++++++++++ tests/lm32/test_lbu.S | 45 ++++++++++++++++++++ tests/lm32/test_lh.S | 45 ++++++++++++++++++++ tests/lm32/test_lhu.S | 45 ++++++++++++++++++++ tests/lm32/test_lw.S | 30 +++++++++++++ tests/lm32/test_modu.S | 35 +++++++++++++++ tests/lm32/test_mul.S | 70 +++++++++++++++++++++++++++++++ tests/lm32/test_muli.S | 45 ++++++++++++++++++++ tests/lm32/test_nor.S | 51 ++++++++++++++++++++++ tests/lm32/test_nori.S | 35 +++++++++++++++ tests/lm32/test_or.S | 51 ++++++++++++++++++++++ tests/lm32/test_orhi.S | 35 +++++++++++++++ tests/lm32/test_ori.S | 35 +++++++++++++++ tests/lm32/test_ret.S | 14 ++++++ tests/lm32/test_sb.S | 30 +++++++++++++ tests/lm32/test_scall.S | 20 +++++++++ tests/lm32/test_sextb.S | 20 +++++++++ tests/lm32/test_sexth.S | 20 +++++++++ tests/lm32/test_sh.S | 30 +++++++++++++ tests/lm32/test_sl.S | 45 ++++++++++++++++++++ tests/lm32/test_sli.S | 30 +++++++++++++ tests/lm32/test_sr.S | 57 +++++++++++++++++++++++++ tests/lm32/test_sri.S | 40 +++++++++++++++++ tests/lm32/test_sru.S | 57 +++++++++++++++++++++++++ tests/lm32/test_srui.S | 40 +++++++++++++++++ tests/lm32/test_sub.S | 75 +++++++++++++++++++++++++++++++++ tests/lm32/test_sw.S | 35 +++++++++++++++ tests/lm32/test_xnor.S | 51 ++++++++++++++++++++++ tests/lm32/test_xnori.S | 35 +++++++++++++++ tests/lm32/test_xor.S | 51 ++++++++++++++++++++++ tests/lm32/test_xori.S | 35 +++++++++++++++ 67 files changed, 3048 insertions(+), 0 deletions(-) create mode 100644 tests/lm32/Makefile create mode 100644 tests/lm32/crt.S create mode 100644 tests/lm32/linker.ld create mode 100644 tests/lm32/macros.inc create mode 100644 tests/lm32/test_add.S create mode 100644 tests/lm32/test_addi.S create mode 100644 tests/lm32/test_and.S create mode 100644 tests/lm32/test_andhi.S create mode 100644 tests/lm32/test_andi.S create mode 100644 tests/lm32/test_b.S create mode 100644 tests/lm32/test_be.S create mode 100644 tests/lm32/test_bg.S create mode 100644 tests/lm32/test_bge.S create mode 100644 tests/lm32/test_bgeu.S create mode 100644 tests/lm32/test_bgu.S create mode 100644 tests/lm32/test_bi.S create mode 100644 tests/lm32/test_bne.S create mode 100644 tests/lm32/test_break.S create mode 100644 tests/lm32/test_bret.S create mode 100644 tests/lm32/test_call.S create mode 100644 tests/lm32/test_calli.S create mode 100644 tests/lm32/test_cmpe.S create mode 100644 tests/lm32/test_cmpei.S create mode 100644 tests/lm32/test_cmpg.S create mode 100644 tests/lm32/test_cmpge.S create mode 100644 tests/lm32/test_cmpgei.S create mode 100644 tests/lm32/test_cmpgeu.S create mode 100644 tests/lm32/test_cmpgeui.S create mode 100644 tests/lm32/test_cmpgi.S create mode 100644 tests/lm32/test_cmpgu.S create mode 100644 tests/lm32/test_cmpgui.S create mode 100644 tests/lm32/test_cmpne.S create mode 100644 tests/lm32/test_cmpnei.S create mode 100644 tests/lm32/test_divu.S create mode 100644 tests/lm32/test_eret.S create mode 100644 tests/lm32/test_lb.S create mode 100644 tests/lm32/test_lbu.S create mode 100644 tests/lm32/test_lh.S create mode 100644 tests/lm32/test_lhu.S create mode 100644 tests/lm32/test_lw.S create mode 100644 tests/lm32/test_modu.S create mode 100644 tests/lm32/test_mul.S create mode 100644 tests/lm32/test_muli.S create mode 100644 tests/lm32/test_nor.S create mode 100644 tests/lm32/test_nori.S create mode 100644 tests/lm32/test_or.S create mode 100644 tests/lm32/test_orhi.S create mode 100644 tests/lm32/test_ori.S create mode 100644 tests/lm32/test_ret.S create mode 100644 tests/lm32/test_sb.S create mode 100644 tests/lm32/test_scall.S create mode 100644 tests/lm32/test_sextb.S create mode 100644 tests/lm32/test_sexth.S create mode 100644 tests/lm32/test_sh.S create mode 100644 tests/lm32/test_sl.S create mode 100644 tests/lm32/test_sli.S create mode 100644 tests/lm32/test_sr.S create mode 100644 tests/lm32/test_sri.S create mode 100644 tests/lm32/test_sru.S create mode 100644 tests/lm32/test_srui.S create mode 100644 tests/lm32/test_sub.S create mode 100644 tests/lm32/test_sw.S create mode 100644 tests/lm32/test_xnor.S create mode 100644 tests/lm32/test_xnori.S create mode 100644 tests/lm32/test_xor.S create mode 100644 tests/lm32/test_xori.S
tests/Makefile +4 -0
@@ -142,6 +142,10 @@ hello-mipsel: hello-mips.c test-cris: $(MAKE) -C cris check +# testsuite for the LM32 port. +test-lm32: + $(MAKE) -C lm32 check + clean: rm -f *~ *.o test-i386.out test-i386.ref \ test-x86_64.log test-x86_64.ref qruncom $(TESTS)
tests/lm32/Makefile new file +102 -0
102 lines not on this page · raw message
tests/lm32/crt.S new file +84 -0
84 lines not on this page · raw message
tests/lm32/linker.ld new file +55 -0
55 lines not on this page · raw message
tests/lm32/macros.inc new file +79 -0
79 lines not on this page · raw message
tests/lm32/test_add.S new file +75 -0
75 lines not on this page · raw message
tests/lm32/test_addi.S new file +56 -0
56 lines not on this page · raw message
tests/lm32/test_and.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_andhi.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name ANDHI_1 +mvi r1, 0 +andhi r3, r1, 0 +check_r3 0 + +test_name ANDHI_2 +mvi r1, 1 +andhi r3, r1, 1 +check_r3 0 + +test_name ANDHI_3 +load r1 0x000f0000 +andhi r3, r1, 1 +check_r3 0x00010000 + +test_name ANDHI_4 +load r1 0xffffffff +andhi r3, r1, 0xffff +check_r3 0xffff0000 + +test_name ANDHI_5 +load r1 0xffffffff +andhi r3, r1, 0 +check_r3 0 + +test_name ANDHI_6 +load r3 0x55aaffff +andhi r3, r3, 0xaaaa +check_r3 0x00aa0000 + +end
tests/lm32/test_andi.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name ANDI_1 +mvi r1, 0 +andi r3, r1, 0 +check_r3 0 + +test_name ANDI_2 +mvi r1, 1 +andi r3, r1, 1 +check_r3 1 + +test_name ANDI_3 +load r1 0x000f0000 +andi r3, r1, 1 +check_r3 0 + +test_name ANDI_4 +load r1 0xffffffff +andi r3, r1, 0xffff +check_r3 0xffff + +test_name ANDI_5 +load r1 0xffffffff +andi r3, r1, 0 +check_r3 0 + +test_name ANDI_6 +load r3 0xffff55aa +andi r3, r3, 0xaaaa +check_r3 0x000000aa + +end
tests/lm32/test_b.S new file +13 -0
@@ -0,0 +1,13 @@ +.include "macros.inc" + +start + +test_name B_1 +load r1 jump +b r1 +tc_fail +end + +jump: +tc_pass +end
tests/lm32/test_be.S new file +48 -0
48 lines not on this page · raw message
tests/lm32/test_bg.S new file +78 -0
78 lines not on this page · raw message
tests/lm32/test_bge.S new file +78 -0
78 lines not on this page · raw message
tests/lm32/test_bgeu.S new file +78 -0
78 lines not on this page · raw message
tests/lm32/test_bgu.S new file +78 -0
78 lines not on this page · raw message
tests/lm32/test_bi.S new file +23 -0
@@ -0,0 +1,23 @@ +.include "macros.inc" + +start + +test_name BI_1 +bi jump +tc_fail +end + +jump_back: +tc_pass +end + +jump: +tc_pass + +test_name BI_2 +bi jump_back +tc_fail + +end + +
tests/lm32/test_bne.S new file +48 -0
48 lines not on this page · raw message
tests/lm32/test_break.S new file +20 -0
@@ -0,0 +1,20 @@ +.include "macros.inc" + +start + +test_name BREAK_1 +mvi r1, 1 +wcsr IE, r1 +insn: +break +check_excp 1 + +test_name BREAK_2 +mv r3, ba +check_r3 insn + +test_name BREAK_3 +rcsr r3, IE +check_r3 4 + +end
tests/lm32/test_bret.S new file +38 -0
@@ -0,0 +1,38 @@ +.include "macros.inc" + +start + +test_name BRET_1 +mvi r1, 4 +wcsr IE, r1 +load ba mark +bret +tc_fail +bi 1f + +mark: +tc_pass + +1: +test_name BRET_2 +rcsr r3, IE +check_r3 5 + +test_name BRET_3 +mvi r1, 0 +wcsr IE, r1 +load ba mark2 +bret +tc_fail +bi 1f + +mark2: +tc_pass + +1: +test_name BRET_4 +rcsr r3, IE +check_r3 0 + +end +
tests/lm32/test_call.S new file +16 -0
@@ -0,0 +1,16 @@ +.include "macros.inc" + +start + +test_name CALL_1 +load r1 mark +call r1 +return: + +tc_fail +end + +mark: +mv r3, ra +check_r3 return +end
tests/lm32/test_calli.S new file +15 -0
@@ -0,0 +1,15 @@ +.include "macros.inc" + +start + +test_name CALLI_1 +calli mark +return: + +tc_fail +end + +mark: +mv r3, ra +check_r3 return +end
tests/lm32/test_cmpe.S new file +40 -0
@@ -0,0 +1,40 @@ +.include "macros.inc" + +start + +test_name CMPE_1 +mvi r1, 0 +mvi r2, 0 +cmpe r3, r1, r2 +check_r3 1 + +test_name CMPE_2 +mvi r1, 0 +mvi r2, 1 +cmpe r3, r1, r2 +check_r3 0 + +test_name CMPE_3 +mvi r1, 1 +mvi r2, 0 +cmpe r3, r1, r2 +check_r3 0 + +test_name CMPE_4 +mvi r3, 0 +mvi r2, 1 +cmpe r3, r3, r2 +check_r3 0 + +test_name CMPE_5 +mvi r3, 0 +mvi r2, 0 +cmpe r3, r3, r2 +check_r3 1 + +test_name CMPE_6 +mvi r3, 0 +cmpe r3, r3, r3 +check_r3 1 + +end
tests/lm32/test_cmpei.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name CMPEI_1 +mvi r1, 0 +cmpei r3, r1, 0 +check_r3 1 + +test_name CMPEI_2 +mvi r1, 0 +cmpei r3, r1, 1 +check_r3 0 + +test_name CMPEI_3 +mvi r1, 1 +cmpei r3, r1, 0 +check_r3 0 + +test_name CMPEI_4 +load r1 0xffffffff +cmpei r3, r1, -1 +check_r3 1 + +test_name CMPEI_5 +mvi r3, 0 +cmpei r3, r3, 0 +check_r3 1 + +test_name CMPEI_6 +mvi r3, 0 +cmpei r3, r3, 1 +check_r3 0 + +end
tests/lm32/test_cmpg.S new file +64 -0
64 lines not on this page · raw message
tests/lm32/test_cmpge.S new file +64 -0
64 lines not on this page · raw message
tests/lm32/test_cmpgei.S new file +55 -0
55 lines not on this page · raw message
tests/lm32/test_cmpgeu.S new file +64 -0
64 lines not on this page · raw message
tests/lm32/test_cmpgeui.S new file +55 -0
55 lines not on this page · raw message
tests/lm32/test_cmpgi.S new file +55 -0
55 lines not on this page · raw message
tests/lm32/test_cmpgu.S new file +64 -0
64 lines not on this page · raw message
tests/lm32/test_cmpgui.S new file +55 -0
55 lines not on this page · raw message
tests/lm32/test_cmpne.S new file +40 -0
@@ -0,0 +1,40 @@ +.include "macros.inc" + +start + +test_name CMPNE_1 +mvi r1, 0 +mvi r2, 0 +cmpne r3, r1, r2 +check_r3 0 + +test_name CMPNE_2 +mvi r1, 0 +mvi r2, 1 +cmpne r3, r1, r2 +check_r3 1 + +test_name CMPNE_3 +mvi r1, 1 +mvi r2, 0 +cmpne r3, r1, r2 +check_r3 1 + +test_name CMPNE_4 +mvi r3, 0 +mvi r2, 1 +cmpne r3, r3, r2 +check_r3 1 + +test_name CMPNE_5 +mvi r3, 0 +mvi r2, 0 +cmpne r3, r3, r2 +check_r3 0 + +test_name CMPNE_6 +mvi r3, 0 +cmpne r3, r3, r3 +check_r3 0 + +end
tests/lm32/test_cmpnei.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name CMPNEI_1 +mvi r1, 0 +cmpnei r3, r1, 0 +check_r3 0 + +test_name CMPNEI_2 +mvi r1, 0 +cmpnei r3, r1, 1 +check_r3 1 + +test_name CMPNEI_3 +mvi r1, 1 +cmpnei r3, r1, 0 +check_r3 1 + +test_name CMPNEI_4 +load r1 0xffffffff +cmpnei r3, r1, -1 +check_r3 0 + +test_name CMPNEI_5 +mvi r3, 0 +cmpnei r3, r3, 0 +check_r3 0 + +test_name CMPNEI_6 +mvi r3, 0 +cmpnei r3, r3, 1 +check_r3 1 + +end
tests/lm32/test_divu.S new file +29 -0
@@ -0,0 +1,29 @@ +.include "macros.inc" + +start + +test_name DIVU_1 +mvi r1, 0 +mvi r2, 1 +divu r3, r1, r2 +check_r3 0 + +test_name DIVU_2 +mvi r1, 1 +mvi r2, 1 +divu r3, r1, r2 +check_r3 1 + +test_name DIVU_3 +mvi r1, 0 +mvi r2, 0 +divu r3, r1, r2 +check_excp 16 + +test_name DIVU_4 +load r1 0xabcdef12 +load r2 0x12345 +divu r3, r1, r2 +check_r3 0x9700 + +end
tests/lm32/test_eret.S new file +38 -0
@@ -0,0 +1,38 @@ +.include "macros.inc" + +start + +test_name ERET_1 +mvi r1, 2 +wcsr IE, r1 +load ea mark +eret +tc_fail +bi 1f + +mark: +tc_pass + +1: +test_name ERET_2 +rcsr r3, IE +check_r3 3 + +test_name ERET_3 +mvi r1, 0 +wcsr IE, r1 +load ea mark2 +eret +tc_fail +bi 1f + +mark2: +tc_pass + +1: +test_name ERET_4 +rcsr r3, IE +check_r3 0 + +end +
tests/lm32/test_lb.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_lbu.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_lh.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_lhu.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_lw.S new file +30 -0
@@ -0,0 +1,30 @@ +.include "macros.inc" + +start + +test_name LW_1 +load r1 data +lw r3, (r1+0) +check_r3 0x7e7f7071 + +test_name LW_2 +lw r3, (r1+4) +check_r3 0x72737475 + +test_name LW_3 +lw r3, (r1+-4) +check_r3 0x7a7b7c7d + +test_name LW_4 +load r3 data +lw r3, (r3+0) +check_r3 0x7e7f7071 + +end + +.data + .align 4 + .byte 0x7a, 0x7b, 0x7c, 0x7d +data: + .byte 0x7e, 0x7f, 0x70, 0x71 + .byte 0x72, 0x73, 0x74, 0x75
tests/lm32/test_modu.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name MODU_1 +mvi r1, 0 +mvi r2, 1 +modu r3, r1, r2 +check_r3 0 + +test_name MODU_2 +mvi r1, 1 +mvi r2, 1 +modu r3, r1, r2 +check_r3 0 + +test_name MODU_3 +mvi r1, 3 +mvi r2, 2 +modu r3, r1, r2 +check_r3 1 + +test_name MODU_4 +mvi r1, 0 +mvi r2, 0 +modu r3, r1, r2 +check_excp 16 + +test_name MODU_5 +load r1 0xabcdef12 +load r2 0x12345 +modu r3, r1, r2 +check_r3 0x3c12 + +end
tests/lm32/test_mul.S new file +70 -0
70 lines not on this page · raw message
tests/lm32/test_muli.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_nor.S new file +51 -0
51 lines not on this page · raw message
tests/lm32/test_nori.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name NORI_1 +mvi r1, 0 +nori r3, r1, 0 +check_r3 0xffffffff + +test_name NORI_2 +mvi r1, 0 +nori r3, r1, 1 +check_r3 0xfffffffe + +test_name NORI_3 +mvi r1, 1 +nori r3, r1, 1 +check_r3 0xfffffffe + +test_name NORI_4 +mvi r1, 1 +nori r3, r1, 0 +check_r3 0xfffffffe + +test_name NORI_5 +load r1 0xaa55aa55 +nori r3, r1, 0x55aa +check_r3 0x55aa0000 + +test_name NORI_6 +load r3 0xaa55aa55 +nori r3, r3, 0x55aa +check_r3 0x55aa0000 + +end
tests/lm32/test_or.S new file +51 -0
51 lines not on this page · raw message
tests/lm32/test_orhi.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name ORHI_1 +mvi r1, 0 +orhi r3, r1, 0 +check_r3 0 + +test_name ORHI_2 +mvi r1, 0 +orhi r3, r1, 1 +check_r3 0x00010000 + +test_name ORHI_3 +load r1 0x00010000 +orhi r3, r1, 1 +check_r3 0x00010000 + +test_name ORHI_4 +mvi r1, 1 +orhi r3, r1, 0 +check_r3 1 + +test_name ORHI_5 +load r1 0xaa55aa55 +orhi r3, r1, 0x55aa +check_r3 0xffffaa55 + +test_name ORHI_6 +load r3 0xaa55aa55 +orhi r3, r3, 0x55aa +check_r3 0xffffaa55 + +end
tests/lm32/test_ori.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name ORI_1 +mvi r1, 0 +ori r3, r1, 0 +check_r3 0 + +test_name ORI_2 +mvi r1, 0 +ori r3, r1, 1 +check_r3 1 + +test_name ORI_3 +mvi r1, 1 +ori r3, r1, 1 +check_r3 1 + +test_name ORI_4 +mvi r1, 1 +ori r3, r1, 0 +check_r3 1 + +test_name ORI_5 +load r1 0xaa55aa55 +ori r3, r1, 0x55aa +check_r3 0xaa55ffff + +test_name ORI_6 +load r3 0xaa55aa55 +ori r3, r3, 0x55aa +check_r3 0xaa55ffff + +end
tests/lm32/test_ret.S new file +14 -0
@@ -0,0 +1,14 @@ +.include "macros.inc" + +start + +test_name RET_1 +load ra mark +ret + +tc_fail +end + +mark: +tc_pass +end
tests/lm32/test_sb.S new file +30 -0
@@ -0,0 +1,30 @@ +.include "macros.inc" + +start + +test_name SB_1 +load r1 data +load r2 0xf0f1f2aa +sb (r1+0), r2 +check_mem data 0xaa000000 + +test_name SB_2 +load r2 0xf0f1f2bb +sb (r1+1), r2 +check_mem data 0xaabb0000 + +test_name SB_3 +load r2 0xf0f1f2cc +sb (r1+-1), r2 +check_mem data0 0x000000cc + +end + +.data + .align 4 +data0: + .byte 0, 0, 0, 0 +data: + .byte 0, 0, 0, 0 +data1: + .byte 0, 0, 0, 0
tests/lm32/test_scall.S new file +20 -0
@@ -0,0 +1,20 @@ +.include "macros.inc" + +start + +test_name SCALL_1 +mvi r1, 1 +wcsr IE, r1 +insn: +scall +check_excp 64 + +test_name SCALL_2 +mv r3, ea +check_r3 insn + +test_name SCALL_3 +rcsr r3, IE +check_r3 2 + +end
tests/lm32/test_sextb.S new file +20 -0
@@ -0,0 +1,20 @@ +.include "macros.inc" + +start + +test_name SEXTB_1 +mvi r1, 0 +sextb r3, r1 +check_r3 0 + +test_name SEXTB_2 +mvi r1, 0x7f +sextb r3, r1 +check_r3 0x0000007f + +test_name SEXTB_3 +mvi r1, 0x80 +sextb r3, r1 +check_r3 0xffffff80 + +end
tests/lm32/test_sexth.S new file +20 -0
@@ -0,0 +1,20 @@ +.include "macros.inc" + +start + +test_name SEXTH_1 +mvi r1, 0 +sexth r3, r1 +check_r3 0 + +test_name SEXTH_2 +load r1 0x7fff +sexth r3, r1 +check_r3 0x00007fff + +test_name SEXTH_3 +load r1 0x8000 +sexth r3, r1 +check_r3 0xffff8000 + +end
tests/lm32/test_sh.S new file +30 -0
@@ -0,0 +1,30 @@ +.include "macros.inc" + +start + +test_name SH_1 +load r1 data +load r2 0xf0f1aaaa +sh (r1+0), r2 +check_mem data 0xaaaa0000 + +test_name SH_2 +load r2 0xf0f1bbbb +sh (r1+2), r2 +check_mem data 0xaaaabbbb + +test_name SH_3 +load r2 0xf0f1cccc +sh (r1+-2), r2 +check_mem data0 0x0000cccc + +end + +.data + .align 4 +data0: + .byte 0, 0, 0, 0 +data: + .byte 0, 0, 0, 0 +data1: + .byte 0, 0, 0, 0
tests/lm32/test_sl.S new file +45 -0
45 lines not on this page · raw message
tests/lm32/test_sli.S new file +30 -0
@@ -0,0 +1,30 @@ +.include "macros.inc" + +start + +test_name SLI_1 +mvi r1, 1 +sli r3, r1, 0 +check_r3 1 + +test_name SLI_2 +mvi r1, 0 +sli r3, r1, 1 +check_r3 0 + +test_name SLI_3 +mvi r1, 1 +sli r3, r1, 31 +check_r3 0x80000000 + +test_name SLI_4 +mvi r1, 16 +sli r3, r1, 31 +check_r3 0 + +test_name SLI_7 +mvi r3, 2 +sli r3, r3, 2 +check_r3 8 + +end
tests/lm32/test_sr.S new file +57 -0
57 lines not on this page · raw message
tests/lm32/test_sri.S new file +40 -0
@@ -0,0 +1,40 @@ +.include "macros.inc" + +start + +test_name SRI_1 +mvi r1, 1 +sri r3, r1, 0 +check_r3 1 + +test_name SRI_2 +mvi r1, 0 +sri r3, r1, 1 +check_r3 0 + +test_name SRI_3 +load r1 0x40000000 +sri r3, r1, 30 +check_r3 1 + +test_name SRI_4 +load r1 0x40000000 +sri r3, r1, 31 +check_r3 0 + +test_name SRI_5 +mvi r3, 2 +sri r3, r3, 2 +check_r3 0 + +test_name SRI_6 +mvi r1, 0xfffffff0 +sri r3, r1, 2 +check_r3 0xfffffffc + +test_name SRI_7 +mvi r1, 0xfffffff0 +sri r3, r1, 4 +check_r3 0xffffffff + +end
tests/lm32/test_sru.S new file +57 -0
57 lines not on this page · raw message
tests/lm32/test_srui.S new file +40 -0
@@ -0,0 +1,40 @@ +.include "macros.inc" + +start + +test_name SRUI_1 +mvi r1, 1 +srui r3, r1, 0 +check_r3 1 + +test_name SRUI_2 +mvi r1, 0 +srui r3, r1, 1 +check_r3 0 + +test_name SRUI_3 +load r1 0x40000000 +srui r3, r1, 30 +check_r3 1 + +test_name SRUI_4 +load r1 0x40000000 +srui r3, r1, 31 +check_r3 0 + +test_name SRUI_5 +mvi r3, 2 +srui r3, r3, 2 +check_r3 0 + +test_name SRUI_6 +mvi r1, 0xfffffff0 +srui r3, r1, 2 +check_r3 0x3ffffffc + +test_name SRUI_7 +mvi r1, 0xfffffff0 +srui r3, r1, 4 +check_r3 0x0fffffff + +end
tests/lm32/test_sub.S new file +75 -0
75 lines not on this page · raw message
tests/lm32/test_sw.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name SW_1 +load r1 data +load r2 0xaabbccdd +sw (r1+0), r2 +check_mem data 0xaabbccdd + +test_name SW_2 +load r2 0x00112233 +sw (r1+4), r2 +check_mem data1 0x00112233 + +test_name SW_3 +load r2 0x44556677 +sw (r1+-4), r2 +check_mem data0 0x44556677 + +test_name SW_4 +sw (r1+0), r1 +lw r3, (r1+0) +check_r3 data + +end + +.data + .align 4 +data0: + .byte 0, 0, 0, 0 +data: + .byte 0, 0, 0, 0 +data1: + .byte 0, 0, 0, 0
tests/lm32/test_xnor.S new file +51 -0
51 lines not on this page · raw message
tests/lm32/test_xnori.S new file +35 -0
@@ -0,0 +1,35 @@ +.include "macros.inc" + +start + +test_name XNORI_1 +mvi r1, 0 +xnori r3, r1, 0 +check_r3 0xffffffff + +test_name XNORI_2 +mvi r1, 0 +xnori r3, r1, 1 +check_r3 0xfffffffe + +test_name XNORI_3 +mvi r1, 1 +xnori r3, r1, 1 +check_r3 0xffffffff + +test_name XNORI_4 +mvi r1, 1 +xnori r3, r1, 0 +check_r3 0xfffffffe + +test_name XNORI_5 +load r1 0xaa55aa55 +xnori r3, r1, 0x5555 +check_r3 0x55aa00ff + +test_name XNORI_6 +load r3 0xaa55aa55 +xnori r3, r3, 0x5555 +check_r3 0x55aa00ff + +end
tests/lm32/test_xor.S new file +51 -0
32 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.2.3
Part of the diff is not shown here. View the raw message.
PATCH 16/17 Add lm32 target to configure
In reply to Michael Walle--- configure | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
configure +7 -3
@@ -280,7 +280,7 @@ else fi case "$cpu" in - alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64) + alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64) cpu="$cpu" ;; i386|i486|i586|i686|i86pc|BePC)
@@ -981,6 +981,7 @@ i386-softmmu \ x86_64-softmmu \ arm-softmmu \ cris-softmmu \ +lm32-softmmu \ m68k-softmmu \ microblaze-softmmu \ mips-softmmu \
@@ -2478,7 +2479,7 @@ echo "docdir=$docdir" >> $config_host_mak echo "confdir=$confdir" >> $config_host_mak case "$cpu" in - i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) + i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) ARCH=$cpu ;; armv4b|armv4l)
@@ -2825,7 +2826,7 @@ target_arch2=`echo $target | cut -d '-' -f 1` target_bigendian="no" case "$target_arch2" in - armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus) + armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus) target_bigendian=yes ;; esac
@@ -2913,6 +2914,9 @@ case "$target_arch2" in target_nptl="yes" target_phys_bits=32 ;; + lm32) + target_phys_bits=32 + ;; m68k) bflt="yes" gdb_xml_files="cf-core.xml cf-fp.xml"
Signature · 1 line
1.7.2.3
PATCH 17/17 MAINTAINERS: add LatticeMico32 maintainer
In reply to Michael WalleAdd me as the lm32-target and machines maintainer.
--- MAINTAINERS | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
MAINTAINERS +12 -0
@@ -70,6 +70,11 @@ M: Edgar E. Iglesias <[email protected]> S: Maintained F: target-cris/ +LM32 +M: Michael Walle <[email protected]> +S: Maintained +F: target-lm32/ + M68K M: Paul Brook <[email protected]> S: Maintained
@@ -202,6 +207,13 @@ M: Edgar E. Iglesias <[email protected]> S: Maintained F: hw/etraxfs.c +LM32 Machines +------------- +EVR32 and uclinux BSP +M: Michael Walle <[email protected]> +S: Maintained +F: hw/lm32_boards.c + M68K Machines ------------- an5206
Signature · 1 line
1.7.2.3
Quoted 8 lines · Michael Walle
This patchset adds support for the LatticeMico32 softcore processor by Lattice Semiconductor.
This is the first part of a larger patchset. It adds target support and two simple BSPs. The second part will add support for the milkymist hardware platform.