target-lm32 updates
Hi Anthony,
this is a pull request for various updates and fixes for the LatticeMico32 target.
Please pull.
changes since v3:
- rebased
- signed pull request
changes since v2:
- rebased
- replaced ifdef HOST_WORDS_BIGENDIAN with be16_to_cpu() in "milkymist-vgafb: swap pixel data in source buffer"
- bumped "target-lm32: move model features to LM32CPU" to v2 patch with minor fixes found by Andreas Faerber
- new patch "hw/lm32: print error if cpu model is not found"
changes since v1:
- rebased
- dropped patch "target-lm32: register helper functions". This is no longer needed.
- added patch "target-lm32: stop VM on illegal or unknown instruction". Was posted as request for comments before. But since there were no comments, include it here.
Thanks,
michael
The following changes since commit 1cf892ca2689c84960b4ce4d2723b6bee453711c:
SPARC: Fix LEON3 power down instruction (2014-01-15 15:37:33 +1000)
are available in the git repository at:
git://github.com/mwalle/qemu tags/lm32-fixes/20140120
for you to fetch changes up to b77202ef2d93722a2c0f6ee467f3664515e2cc21:
hw/lm32: print error if cpu model is not found (2014-01-20 19:49:13 +0100)
----------------------------------------------------------------
Antony Pavlov (1):
milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()
Michael Walle (11):
lm32_sys: increase test case name length limit
tests: lm32: new rule for single test cases lm32_uart/lm32_juart: use qemu_chr_fe_write_all()
milkymist-vgafb: swap pixel data in source buffer
target-lm32: kill cpu_abort() calls
target-lm32: move model features to LM32CPU
target-lm32: add breakpoint/watchpoint support
lm32_sys: print test result on stderr
lm32_sys: dump cpu state if test case fails
target-lm32: stop VM on illegal or unknown instruction hw/lm32: print error if cpu model is not found
hw/char/lm32_juart.c | 2 +- hw/char/lm32_uart.c | 2 +- hw/char/milkymist-uart.c | 2 +- hw/display/milkymist-vgafb_template.h | 1 + hw/lm32/lm32_boards.c | 10 ++ hw/lm32/milkymist.c | 5 + hw/misc/lm32_sys.c | 7 +- target-lm32/TODO | 2 - target-lm32/cpu-qom.h | 6 + target-lm32/cpu.c | 188 +++++++++++++++++++++++++++- target-lm32/cpu.h | 34 ++++-- target-lm32/helper.c | 217 ++++++++++++++------------------- target-lm32/helper.h | 4 + target-lm32/op_helper.c | 75 +++++++++++- target-lm32/translate.c | 178 +++++++++++++++++---------- tests/tcg/lm32/Makefile | 3 + 16 files changed, 529 insertions(+), 207 deletions(-)
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL v4 01/12] lm32_sys: increase test case name length limit
The new MMU tests use longer names.
--- hw/misc/lm32_sys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/lm32_sys.c +2 -2
@@ -42,7 +42,7 @@ enum { R_MAX }; -#define MAX_TESTNAME_LEN 16 +#define MAX_TESTNAME_LEN 32#define TYPE_LM32_SYS "lm32-sys"#define LM32_SYS (obj) OBJECT_CHECK(LM32SysState, (obj), TYPE_LM32_SYS)
@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-16s %s\n" , testname, (value) ?"FAILED" :"OK" ); +qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" );break ;case R_TESTNAME : s->regs[addr] = value;
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PULL v4 01/12] lm32_sys: increase test case name length limit
Quoted 21 lines · Michael Walle
The new MMU tests use longer names.
Signed-off-by Michael Walle <[email protected]>--- hw/misc/lm32_sys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/misc/lm32_sys.c +1
-1@@ -42,7 +42,7 @@ enum { R_MAX }; -#define MAX_TESTNAME_LEN 16 +#define MAX_TESTNAME_LEN 32#define TYPE_LM32_SYS "lm32-sys"#define LM32_SYS (obj) OBJECT_CHECK(LM32SysState, (obj), TYPE_LM32_SYS)
hw/misc/lm32_sys.c static void sys_write(void *opaque, hwaddr addr, · line 83
Quoted 5 lines
hw/misc/lm32_sys.c +1
-1@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-16s %s\n" , testname, (value) ?"FAILED" :"OK" ); +qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" );
You could avoid the duplication of the 32 here by using
qemu_log("TCG %-*s %s\n", MAX_TESTNAME_LEN, testname, value ?
"FAILED" : "OK");
thanks
-- PMM
[Qemu-devel] [PULL v4 02/12] tests: lm32: new rule for single test cases
In reply to Michael WalleIntroduce new target "check_%" to run indiviudal test caes, eg.
make check_mmu
--- tests/tcg/lm32/Makefile | 3 +++ 1 file changed, 3 insertions(+)
tests/tcg/lm32/Makefile +3 -0
@@ -101,5 +101,8 @@ check: $(CRT) $(SYS) $(TESTCASES) $(SIM) $(SIMFLAGS) ./$$case; \ done +check_%: test_%.tst $(CRT) $(SYS) + $(SIM) $(SIMFLAGS) $< + clean: $(RM) -fr $(TESTCASES) $(CRT)
Signature · 1 line
1.7.10.4
Peter Maydell
Reviewed-byRe: [Qemu-devel] [PULL v4 02/12] tests: lm32: new rule for single test cases
Quoted 2 lines · Michael Walle
Introduce new target "check_%" to run indiviudal test caes, eg.
makecheck_mmu
"individual". Otherwise
Quoted 11 lines
Signed-off-by Michael Walle <[email protected]>--- tests/tcg/lm32/Makefile | 3 +++ 1 file changed, 3 insertions(+)tests/tcg/lm32/Makefile +0
-0
tests/tcg/lm32/Makefile check: $(CRT) $(SYS) $(TESTCASES) · line 108
Quoted 8 lines
tests/tcg/lm32/Makefile +3
-0@@ -101,5 +101,8 @@ check: $(CRT) $(SYS) $(TESTCASES) $(SIM) $(SIMFLAGS) ./$$case; \ done +check_%: test_%.tst $(CRT) $(SYS) + $(SIM) $(SIMFLAGS) $< + clean: $(RM) -fr $(TESTCASES) $(CRT)
You could reimplement the 'check' target to just
depend on $(TESTCASES:test_%.tst=check_%)
rather than doing an explicit loop if you like, but that's optional.
thanks
-- PMM
[Qemu-devel] [PULL v4 04/12] lm32_uart/lm32_juart: use qemu_chr_fe_write_all()
In reply to Michael Walleqemu_chr_fe_write() may return EAGAIN. Therefore, use qemu_chr_fe_write_all().
--- hw/char/lm32_juart.c | 2 +- hw/char/lm32_uart.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/char/lm32_juart.c +1 -1
@@ -75,7 +75,7 @@ void lm32_juart_set_jtx(DeviceState *d, uint32_t jtx) s->jtx = jtx;if (s->chr) { -qemu_chr_fe_write (s->chr, &ch,1 ); +qemu_chr_fe_write_all (s->chr, &ch,1 ); } }
hw/char/lm32_uart.c +1 -1
@@ -177,7 +177,7 @@ static void uart_write(void *opaque, hwaddr addr,switch (addr) {case R_RXTX :if (s->chr) { -qemu_chr_fe_write (s->chr, &ch,1 ); +qemu_chr_fe_write_all (s->chr, &ch,1 ); }break ;case R_IER :
Signature · 1 line
1.7.10.4
Peter Maydell
Reviewed-byRe: [Qemu-devel] [PULL v4 04/12] lm32_uart/lm32_juart: use qemu_chr_fe_write_all()
Quoted 4 lines · Michael Walle
qemu_chr_fe_write()may return EAGAIN. Therefore, useqemu_chr_fe_write_all().Signed-off-by Michael Walle <[email protected]>
-- PMM
[Qemu-devel] [PULL v4 03/12] milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()
In reply to Michael WalleFrom: Antony Pavlov <[email protected]>
qemu_chr_fe_write() is capable of returning 0
to indicate EAGAIN (and friends) and we don't
handle this.
Just change it to qemu_chr_fe_write_all() to fix.
--- hw/char/milkymist-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/milkymist-uart.c +1 -1
@@ -124,7 +124,7 @@ static void uart_write(void *opaque, hwaddr addr, uint64_t value,switch (addr) {case R_RXTX :if (s->chr) { -qemu_chr_fe_write (s->chr, &ch,1 ); +qemu_chr_fe_write_all (s->chr, &ch,1 ); } s->regs[R_STAT ] |=STAT_TX_EVT ;break ;
Signature · 1 line
1.7.10.4
Peter Maydell
Reviewed-byRe: [Qemu-devel] [PULL v4 03/12] milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()
Quoted 6 lines · Michael Walle
From: Antony Pavlov <[email protected]>
qemu_chr_fe_write()is capable of returning 0
to indicate EAGAIN (and friends) and we don't
handle this.
Quoted 6 lines
Just change it to
qemu_chr_fe_write_all()to fix.Reported-by Peter Crosthwaite <[email protected]>Signed-off-by Antony Pavlov <[email protected]>Signed-off-by Michael Walle <[email protected]>
thanks
-- PMM
[Qemu-devel] [PULL v4 06/12] target-lm32: kill cpu_abort() calls
In reply to Michael WalleInstead of killing QEMU, translate instructions which are not available on the CPU model as a noop and issue a log message at translation time.
On the real hardware CPU unknown opcodes results in undefined behaviour.
These changes prepare the removal of CPULM32State from DisasContext.
--- target-lm32/translate.c | 72 ++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 32 deletions(-)
target-lm32/translate.c +40 -32
@@ -80,7 +80,6 @@ typedef struct DisasContext {unsigned int tb_flags, synced_flags;/* tb dependent flags. */ int is_jmp; -int nr_nops;struct TranslationBlock *tb;int singlestep_enabled; } DisasContext;
@@ -422,7 +421,8 @@ static void dec_divu(DisasContext *dc)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" ); +qemu_log_mask (LOG_GUEST_ERROR ,"hardware divider is not available\n" ); +return ; } l1 =gen_new_label ();
@@ -500,7 +500,8 @@ static void dec_modu(DisasContext *dc)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" ); +qemu_log_mask (LOG_GUEST_ERROR ,"hardware divider is not available\n" ); +return ; } l1 =gen_new_label ();
@@ -521,7 +522,9 @@ static void dec_mul(DisasContext *dc) }if (!(dc->env->features &LM32_FEATURE_MULTIPLY )) { -cpu_abort (dc->env,"hardware multiplier is not available\n" ); +qemu_log_mask (LOG_GUEST_ERROR , +"hardware multiplier is not available\n" ); +return ; }if (dc->format ==OP_FMT_RI ) {
@@ -590,7 +593,8 @@ static void dec_scall(DisasContext *dc) }else if (dc->imm5 ==2 ) {LOG_DIS ("break\n" ); }else { -cpu_abort (dc->env,"invalid opcode\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"invalid opcode @0x%x" , dc->pc); +return ; }if (dc->imm5 ==7 ) {
@@ -647,10 +651,10 @@ static void dec_rcsr(DisasContext *dc)case CSR_WP1 :case CSR_WP2 :case CSR_WP3 : -cpu_abort (dc->env,"invalid read access csr=%x\n" , dc->csr); +qemu_log_mask (LOG_GUEST_ERROR ,"invalid read access csr=%x\n" , dc->csr);break ;default : -cpu_abort (dc->env,"read_csr: unknown csr=%x\n" , dc->csr); +qemu_log_mask (LOG_GUEST_ERROR ,"read_csr: unknown csr=%x\n" , dc->csr);break ; } }
@@ -672,7 +676,9 @@ 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" ); +qemu_log_mask (LOG_GUEST_ERROR , +"hardware sign extender is not available\n" ); +return ; }tcg_gen_ext8s_tl (cpu_R[dc->r2], cpu_R[dc->r0]);
@@ -683,7 +689,9 @@ 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" ); +qemu_log_mask (LOG_GUEST_ERROR , +"hardware sign extender is not available\n" ); +return ; }tcg_gen_ext16s_tl (cpu_R[dc->r2], cpu_R[dc->r0]);
@@ -710,7 +718,8 @@ static void dec_sl(DisasContext *dc) }if (!(dc->env->features &LM32_FEATURE_SHIFT )) { -cpu_abort (dc->env,"hardware shifter is not available\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"hardware shifter is not available\n" ); +return ; }if (dc->format ==OP_FMT_RI ) {
@@ -736,7 +745,9 @@ static void dec_sr(DisasContext *dc)/* TODO: check r1 == 1 during runtime */ }else {if (dc->imm5 !=1 ) { -cpu_abort (dc->env,"hardware shifter is not available\n" ); +qemu_log_mask (LOG_GUEST_ERROR , +"hardware shifter is not available\n" ); +return ; } } }
@@ -764,7 +775,9 @@ static void dec_sru(DisasContext *dc)/* TODO: check r1 == 1 during runtime */ }else {if (dc->imm5 !=1 ) { -cpu_abort (dc->env,"hardware shifter is not available\n" ); +qemu_log_mask (LOG_GUEST_ERROR , +"hardware shifter is not available\n" ); +return ; } } }
@@ -802,7 +815,7 @@ static void dec_user(DisasContext *dc) {LOG_DIS ("user" ); -cpu_abort (dc->env,"user insn undefined\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"user instruction undefined\n" ); }static void dec_wcsr (DisasContext *dc)
@@ -868,7 +881,9 @@ static void dec_wcsr(DisasContext *dc)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); +qemu_log_mask (LOG_GUEST_ERROR , +"breakpoint #%i is not available\n" , no); +break ; }tcg_gen_mov_tl (cpu_bp[no], cpu_R[dc->r1]);break ;
@@ -878,16 +893,20 @@ static void dec_wcsr(DisasContext *dc)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); +qemu_log_mask (LOG_GUEST_ERROR , +"watchpoint #%i is not available\n" , no); +break ; }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); +qemu_log_mask (LOG_GUEST_ERROR ,"invalid write access csr=%x\n" , + dc->csr);break ;default : -cpu_abort (dc->env,"write_csr unknown csr=%x\n" , dc->csr); +qemu_log_mask (LOG_GUEST_ERROR ,"write_csr: unknown csr=%x\n" , + dc->csr);break ; } }
@@ -933,7 +952,7 @@ static void dec_xor(DisasContext *dc)static void dec_ill (DisasContext *dc) { -cpu_abort (dc->env,"unknown opcode 0x%02x\n" , dc->opcode); +qemu_log_mask (LOG_GUEST_ERROR ,"invalid opcode 0x%02x\n" , dc->opcode); }typedef void (*DecoderInfo )(DisasContext *dc);
@@ -959,18 +978,6 @@ static inline void decode(DisasContext *dc, uint32_t ir) dc->ir = ir;LOG_DIS ("%8.8x\t" , dc->ir); -/* try guessing 'empty' instruction memory, although it may be a valid -* 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" ); - } - } - dc->opcode =EXTRACT_FIELD (ir,26 ,31 ); dc->imm5 =EXTRACT_FIELD (ir,0 ,4 );
@@ -1034,10 +1041,11 @@ void gen_intermediate_code_internal(LM32CPU *cpu, dc->is_jmp =DISAS_NEXT ; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; - dc->nr_nops =0 ;if (pc_start &3 ) { -cpu_abort (env,"LM32: unaligned PC=%x\n" , pc_start); +qemu_log_mask (LOG_GUEST_ERROR , +"unaligned PC=%x. Ignoring lowest bits.\n" , pc_start); + pc_start &= ~3 ; } next_page_start = (pc_start &TARGET_PAGE_MASK ) +TARGET_PAGE_SIZE ;
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL v4 11/12] target-lm32: stop VM on illegal or unknown instruction
In reply to Michael WalleInstead of translating the instruction to a no-op, pause the VM and display a message to the user.
As a side effect, this also works for instructions where the operands are only known at runtime.
--- target-lm32/helper.h | 1 + target-lm32/op_helper.c | 17 +++++++++ target-lm32/translate.c | 91 +++++++++++++++++++++++++++++++---------------- 3 files changed, 79 insertions(+), 30 deletions(-)
target-lm32/helper.h +1 -0
@@ -13,5 +13,6 @@ DEF_HELPER_1(rcsr_im, i32, env) DEF_HELPER_1(rcsr_ip, i32, env) DEF_HELPER_1(rcsr_jtx, i32, env) DEF_HELPER_1(rcsr_jrx, i32, env) +DEF_HELPER_1(ill, void, env)#include "exec/def-helper.h"
target-lm32/op_helper.c +17 -0
@@ -8,6 +8,10 @@#include "exec/softmmu_exec.h" +#ifndef CONFIG_USER_ONLY +#include "sysemu/sysemu.h" +#endif +#if !defined(CONFIG_USER_ONLY )#define MMUSUFFIX _mmu#define SHIFT 0
@@ -39,6 +43,19 @@ void HELPER(hlt)(CPULM32State *env)cpu_loop_exit (env); } +void HELPER (ill )(CPULM32State *env) +{ +#ifndef CONFIG_USER_ONLY +CPUState *cs =CPU (lm32_env_get_cpu (env)); +fprintf (stderr,"VM paused due to illegal instruction. " +"Connect a debugger or switch to the monitor console " +"to find out more.\n" ); +qemu_system_vmstop_request (RUN_STATE_PAUSED ); + cs->halted =1 ; +raise_exception (env,EXCP_HALTED ); +#endif +} +void HELPER (wcsr_bp )(CPULM32State *env,uint32_t bp,uint32_t idx) {uint32_t addr = bp & ~1 ;
target-lm32/translate.c +61 -30
192 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PULL v4 11/12] target-lm32: stop VM on illegal or unknown instruction
Quoted 44 lines · Michael Walle
Instead of translating the instruction to a no-op, pause the VM and display a message to the user.
As a side effect, this also works for instructions where the operands are only known at runtime.
Signed-off-by Michael Walle <[email protected]>--- target-lm32/helper.h | 1 + target-lm32/op_helper.c | 17 +++++++++ target-lm32/translate.c | 91 +++++++++++++++++++++++++++++++---------------- 3 files changed, 79 insertions(+), 30 deletions(-)target-lm32/helper.h +1
-0@@ -13,5 +13,6 @@ DEF_HELPER_1(rcsr_im, i32, env) DEF_HELPER_1(rcsr_ip, i32, env) DEF_HELPER_1(rcsr_jtx, i32, env) DEF_HELPER_1(rcsr_jrx, i32, env) +DEF_HELPER_1(ill, void, env)#include "exec/def-helper.h" target-lm32/op_helper.c +5
-0@@ -8,6 +8,10 @@#include "exec/softmmu_exec.h" +#ifndef CONFIG_USER_ONLY +#include "sysemu/sysemu.h" +#endif +#if !defined(CONFIG_USER_ONLY )#define MMUSUFFIX _mmu#define SHIFT 0@@ -39,6 +43,19 @@ void HELPER(hlt)(CPULM32State *env)cpu_loop_exit (env); } +void HELPER (ill )(CPULM32State *env)
target-lm32/op_helper.c void HELPER(hlt)(CPULM32State *env) · line 56
Quoted 10 lines
target-lm32/op_helper.c +10
-0+{ +#ifndef CONFIG_USER_ONLY +CPUState *cs =CPU (lm32_env_get_cpu (env)); +fprintf (stderr,"VM paused due to illegal instruction. " +"Connect a debugger or switch to the monitor console " +"to find out more.\n" ); +qemu_system_vmstop_request (RUN_STATE_PAUSED ); + cs->halted =1 ; +raise_exception (env,EXCP_HALTED ); +#endif
Not really convinced this is a great idea. "This one target CPU type does something that none of the others do" seems less than ideal for QEMU as a whole.
Quoted 57 lines
target-lm32/op_helper.c +2
-0+} +void HELPER (wcsr_bp )(CPULM32State *env,uint32_t bp,uint32_t idx) {uint32_t addr = bp & ~1 ;target-lm32/translate.c +9
-3@@ -122,6 +122,12 @@ static inline void t_gen_raise_exception(DisasContext *dc, uint32_t index)tcg_temp_free_i32 (tmp); } +static inline void t_gen_illegal_insn (DisasContext *dc) +{ +tcg_gen_movi_tl (cpu_pc, dc->pc); +gen_helper_ill (cpu_env); +} +static void gen_goto_tb (DisasContext *dc,int n,target_ulong dest) {TranslationBlock *tb;@@ -425,6 +431,7 @@ static void dec_divu(DisasContext *dc)if (!(dc->features &LM32_FEATURE_DIVIDE )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware divider is not available\n" ); +t_gen_illegal_insn (dc);return ; }@@ -504,6 +511,7 @@ static void dec_modu(DisasContext *dc)if (!(dc->features &LM32_FEATURE_DIVIDE )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware divider is not available\n" ); +t_gen_illegal_insn (dc);return ; }@@ -527,6 +535,7 @@ static void dec_mul(DisasContext *dc)if (!(dc->features &LM32_FEATURE_MULTIPLY )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware multiplier is not available\n" ); +t_gen_illegal_insn (dc);return ; }@@ -595,17 +604,18 @@ static void dec_scall(DisasContext *dc)LOG_DIS ("scall\n" ); }else if (dc->imm5 ==2 ) {LOG_DIS ("break\n" ); - }else { -qemu_log_mask (LOG_GUEST_ERROR ,"invalid opcode @0x%x" , dc->pc); -return ; }if (dc->imm5 ==7 ) {tcg_gen_movi_tl (cpu_pc, dc->pc);
target-lm32/translate.c static void dec_scall(DisasContext *dc) · line 619
Quoted 10 lines
target-lm32/translate.c +5
-1t_gen_raise_exception (dc,EXCP_SYSTEMCALL ); - }else { + }else if (dc->imm5 ==2 ) {tcg_gen_movi_tl (cpu_pc, dc->pc);t_gen_raise_exception (dc,EXCP_BREAKPOINT ); + }else { +qemu_log_mask (LOG_GUEST_ERROR ,"invalid opcode @0x%x" , dc->pc); +t_gen_illegal_insn (dc); +return ; }
This leaves this function with two consecutive identical if..elseif..else
ladders: why not combine them together? (optionally, use switch(dc->imm5).)
The rest looks OK.
thanks
-- PMM
Re: [Qemu-devel] [PULL v4 11/12] target-lm32: stop VM on illegal or unknown instruction
Am Samstag, 1. Februar 2014, 19:06:40 schrieb Peter Maydell:
Quoted 53 lines · Michael Walle
Quoted 52 lines
Instead of translating the instruction to a no-op, pause the VM and display a message to the user.
As a side effect, this also works for instructions where the operands are only known at runtime.
Signed-off-by Michael Walle <[email protected]>---
target-lm32/helper.h | 1 + target-lm32/op_helper.c | 17 +++++++++ target-lm32/translate.c | 91+++++++++++++++++++++++++++++++---------------- 3 files changed, 79 insertions(+), 30 deletions(-)
target-lm32/helper.h +1
-0@@ -13,5 +13,6 @@ DEF_HELPER_1(rcsr_im, i32, env) DEF_HELPER_1(rcsr_ip, i32, env) DEF_HELPER_1(rcsr_jtx, i32, env) DEF_HELPER_1(rcsr_jrx, i32, env) +DEF_HELPER_1 (ill, void, env)#include "
exec/def-helper.h"target-lm32/op_helper.c +4
-0@@ -8,6 +8,10 @@#include "exec/softmmu_exec.h" +#ifndef CONFIG_USER_ONLY +#include "sysemu/sysemu.h" +#endif +#if !defined(CONFIG_USER_ONLY )#define MMUSUFFIX _mmu#define SHIFT 0
target-lm32/op_helper.c +0
-0@@ -39,6 +43,19 @@ void HELPER(hlt)(CPULM32State *env)cpu_loop_exit (env); }
Quoted 15 lines
target-lm32/op_helper.c void HELPER(hlt)(CPULM32State *env) · line 56
Quoted 11 lines
target-lm32/op_helper.c +11
-0+void HELPER (ill )(CPULM32State *env) +{ +#ifndef CONFIG_USER_ONLY +CPUState *cs =CPU (lm32_env_get_cpu (env)); +fprintf (stderr,"VM paused due to illegal instruction. " +"Connect a debugger or switch to the monitor console " +"to find out more.\n" ); +qemu_system_vmstop_request (RUN_STATE_PAUSED ); + cs->halted =1 ; +raise_exception (env,EXCP_HALTED ); +#endif Not really convinced this is a great idea. "This one target CPU type does something that none of the others do" seems less than ideal for QEMU as a whole.
this was discussed some time ago. unfortunately, i don't find the thread atm.
the particular problem with the lm32 target is that there is no defined behaviour if some unsupported opcode is executed on the real hardware, esp. there are no exceptions if that happens.
therefore the suggested behaviour was to just stop the emulation and give the developer the chance to look at it by connecting a debugger.
keep in mind that the lm32 target is more a development aid, rather than a real virtualization target.
-michael
[Qemu-devel] [PULL v4 12/12] hw/lm32: print error if cpu model is not found
In reply to Michael WalleQEMU crashed if a the given cpu_model is not found.
--- hw/lm32/lm32_boards.c | 10 ++++++++++ hw/lm32/milkymist.c | 5 +++++ 2 files changed, 15 insertions(+)
hw/lm32/lm32_boards.c +10 -0
@@ -101,6 +101,11 @@ static void lm32_evr_init(QEMUMachineInitArgs *args) cpu_model ="lm32-full" ; } cpu =cpu_lm32_init (cpu_model); +if (cpu ==NULL ) { +fprintf (stderr,"qemu: unable to find CPU '%s'\n" , cpu_model); +exit (1 ); + } + env = &cpu->env; reset_info->cpu = cpu;
@@ -198,6 +203,11 @@ static void lm32_uclinux_init(QEMUMachineInitArgs *args) cpu_model ="lm32-full" ; } cpu =cpu_lm32_init (cpu_model); +if (cpu ==NULL ) { +fprintf (stderr,"qemu: unable to find CPU '%s'\n" , cpu_model); +exit (1 ); + } + env = &cpu->env; reset_info->cpu = cpu;
hw/lm32/milkymist.c +5 -0
@@ -108,6 +108,11 @@ milkymist_init(QEMUMachineInitArgs *args) cpu_model ="lm32-full" ; } cpu =cpu_lm32_init (cpu_model); +if (cpu ==NULL ) { +fprintf (stderr,"qemu: unable to find CPU '%s'\n" , cpu_model); +exit (1 ); + } + env = &cpu->env; reset_info->cpu = cpu;
Signature · 1 line
1.7.10.4
Peter Maydell
Reviewed-byRe: [Qemu-devel] [PULL v4 12/12] hw/lm32: print error if cpu model is not found
Quoted 3 lines · Michael Walle
QEMU crashed if a the given
cpu_modelis not found.Signed-off-by Michael Walle <[email protected]>
-- PMM
[Qemu-devel] [PULL v4 07/12] target-lm32: move model features to LM32CPU
In reply to Michael WalleThis allows us to completely remove CPULM32State from DisasContext. Instead, copy the fields we need to DisasContext.
--- target-lm32/cpu-qom.h | 6 ++ target-lm32/cpu.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++- target-lm32/cpu.h | 7 +- target-lm32/helper.c | 128 +------------------------------- target-lm32/translate.c | 29 +++++--- 5 files changed, 215 insertions(+), 142 deletions(-)
target-lm32/cpu-qom.h +6 -0
@@ -60,6 +60,12 @@ typedef struct LM32CPU {/*< public >*/ CPULM32State env; + +uint32_t revision; +uint8_t num_interrupts; +uint8_t num_breakpoints; +uint8_t num_watchpoints; +uint32_t features; }LM32CPU ;static inline LM32CPU *lm32_env_get_cpu (CPULM32State *env)
target-lm32/cpu.c +186 -1
229 lines not on this page · raw message
target-lm32/cpu.h +2 -5
@@ -177,23 +177,20 @@ struct CPULM32State {DeviceState *juart_state;/* processor core features */ -uint32_t features;uint32_t flags; -uint8_t num_bps; -uint8_t num_wps; };#include "cpu-qom.h" LM32CPU *cpu_lm32_init (const char *cpu_model); -void cpu_lm32_list (FILE *f,fprintf_function cpu_fprintf);int cpu_lm32_exec (CPULM32State *s);/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ int cpu_lm32_signal_handler (int host_signum,void *pinfo,void *puc); +void lm32_cpu_list (FILE *f,fprintf_function cpu_fprintf);void lm32_translate_init (void );void cpu_lm32_set_phys_msb_ignore (CPULM32State *env,int value);
@@ -206,7 +203,7 @@ static inline CPULM32State *cpu_init(const char *cpu_model)return &cpu->env; } -#define cpu_list cpu_lm32_list +#define cpu_list lm32_cpu_list#define cpu_exec cpu_lm32_exec#define cpu_gen_code cpu_lm32_gen_code#define cpu_signal_handler cpu_lm32_signal_handler
target-lm32/helper.c +4 -124
140 lines not on this page · raw message
target-lm32/translate.c +17 -12
@@ -64,7 +64,6 @@ enum {/* This is the state at translation time. */ typedef struct DisasContext { - CPULM32State *env; target_ulong pc; /* Decoder. */
@@ -82,6 +81,10 @@ typedef struct DisasContext {struct TranslationBlock *tb;int singlestep_enabled; + +uint32_t features; +uint8_t num_breakpoints; +uint8_t num_watchpoints; } DisasContext;static const char *regnames[] = {
@@ -420,7 +423,7 @@ static void dec_divu(DisasContext *dc)LOG_DIS ("divu r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); -if (!(dc->env->features &LM32_FEATURE_DIVIDE )) { +if (!(dc->features &LM32_FEATURE_DIVIDE )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware divider is not available\n" );return ; }
@@ -499,7 +502,7 @@ static void dec_modu(DisasContext *dc)LOG_DIS ("modu r%d, r%d, %d\n" , dc->r2, dc->r0, dc->r1); -if (!(dc->env->features &LM32_FEATURE_DIVIDE )) { +if (!(dc->features &LM32_FEATURE_DIVIDE )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware divider is not available\n" );return ; }
@@ -521,7 +524,7 @@ static void dec_mul(DisasContext *dc)LOG_DIS ("mul r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); } -if (!(dc->env->features &LM32_FEATURE_MULTIPLY )) { +if (!(dc->features &LM32_FEATURE_MULTIPLY )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware multiplier is not available\n" );return ;
@@ -675,7 +678,7 @@ 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 )) { +if (!(dc->features &LM32_FEATURE_SIGN_EXTEND )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware sign extender is not available\n" );return ;
@@ -688,7 +691,7 @@ 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 )) { +if (!(dc->features &LM32_FEATURE_SIGN_EXTEND )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware sign extender is not available\n" );return ;
@@ -717,7 +720,7 @@ static void dec_sl(DisasContext *dc)LOG_DIS ("sl r%d, r%d, r%d\n" , dc->r2, dc->r0, dc->r1); } -if (!(dc->env->features &LM32_FEATURE_SHIFT )) { +if (!(dc->features &LM32_FEATURE_SHIFT )) {qemu_log_mask (LOG_GUEST_ERROR ,"hardware shifter is not available\n" );return ; }
@@ -740,7 +743,7 @@ static void dec_sr(DisasContext *dc)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->features &LM32_FEATURE_SHIFT )) {if (dc->format ==OP_FMT_RI ) {/* TODO: check r1 == 1 during runtime */ }else {
@@ -770,7 +773,7 @@ static void dec_sru(DisasContext *dc)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->features &LM32_FEATURE_SHIFT )) {if (dc->format ==OP_FMT_RI ) {/* TODO: check r1 == 1 during runtime */ }else {
@@ -880,7 +883,7 @@ static void dec_wcsr(DisasContext *dc)case CSR_BP2 :case CSR_BP3 : no = dc->csr -CSR_BP0 ; -if (dc->env->num_bps <= no) { +if (dc->num_breakpoints <= no) {qemu_log_mask (LOG_GUEST_ERROR ,"breakpoint #%i is not available\n" , no);break ;
@@ -892,7 +895,7 @@ static void dec_wcsr(DisasContext *dc)case CSR_WP2 :case CSR_WP3 : no = dc->csr -CSR_WP0 ; -if (dc->env->num_wps <= no) { +if (dc->num_watchpoints <= no) {qemu_log_mask (LOG_GUEST_ERROR ,"watchpoint #%i is not available\n" , no);break ;
@@ -1033,7 +1036,9 @@ void gen_intermediate_code_internal(LM32CPU *cpu,int max_insns; pc_start = tb->pc; - dc->env = env; + dc->features = cpu->features; + dc->num_breakpoints = cpu->num_breakpoints; + dc->num_watchpoints = cpu->num_watchpoints; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf +OPC_MAX_SIZE ;
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL v4 05/12] milkymist-vgafb: swap pixel data in source buffer
In reply to Michael WalleIn commit fc97bb5ba3e7239c0b6d24095df6784868dfebbf the lduw_raw() call was eliminated. But we are reading from the target buffer a 16-bit value, which is in big-endian format. Therefore, swap the bytes if we are building for a little-endian host.
--- hw/display/milkymist-vgafb_template.h | 1 + 1 file changed, 1 insertion(+)
hw/display/milkymist-vgafb_template.h +1 -0
@@ -62,6 +62,7 @@ static void glue(draw_line_, BITS)(void *opaque, uint8_t *d, const uint8_t *s,while (width--) {memcpy (&rgb565, s,sizeof (rgb565)); + rgb565 =be16_to_cpu (rgb565); r = ((rgb565 >>11 ) &0x1f ) <<3 ; g = ((rgb565 >>5 ) &0x3f ) <<2 ; b = ((rgb565 >>0 ) &0x1f ) <<3 ;
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PULL v4 05/12] milkymist-vgafb: swap pixel data in source buffer
Quoted 4 lines · Michael Walle
In commit
fc97bb5ba3e7239c0b6d24095df6784868dfebbfthelduw_raw()call was eliminated. But we are reading from the target buffer a 16-bit value, which is in big-endian format. Therefore, swap the bytes if we are building for a little-endian host.
Paolo, can you remember why you included this change in that commit? It purports to just be moving the display devices around but it seems to have included the introduction of this bug, and also a removal of a lduw_raw() call from (what is now) hw/display/blizzard_template.h which I suspect is also wrong...
Quoted 11 lines
Cc Paolo Bonzini <[email protected]>Signed-off-by Michael Walle <[email protected]>--- hw/display/milkymist-vgafb_template.h | 1 + 1 file changed, 1 insertion(+)hw/display/milkymist-vgafb_template.h +0
-0
hw/display/milkymist-vgafb_template.h static void glue(draw_line_, BITS)(void *opaque, uint8_t *d, const uint8_t *s, · line 65
Quoted 4 lines
hw/display/milkymist-vgafb_template.h +1
-0@@ -62,6 +62,7 @@ static void glue(draw_line_, BITS)(void *opaque, uint8_t *d, const uint8_t *s,while (width--) {memcpy (&rgb565, s,sizeof (rgb565)); + rgb565 =be16_to_cpu (rgb565);
If we know the framebuffer is always bigendian (regardless of the target CPU endianness) then rather than memcpy and then byteswap we might as well just
rgb565 = lduw_be_p(s);
I think.
hw/display/milkymist-vgafb_template.h static void glue(draw_line_, BITS)(void *opaque, uint8_t *d, const uint8_t *s, · line 68
Quoted 3 lines
hw/display/milkymist-vgafb_template.h +0
-0r = ((rgb565 >>11 ) &0x1f ) <<3 ; g = ((rgb565 >>5 ) &0x3f ) <<2 ; b = ((rgb565 >>0 ) &0x1f ) <<3 ;
thanks
-- PMM
Re: [Qemu-devel] [PULL v4 05/12] milkymist-vgafb: swap pixel data in source buffer
Il 01/02/2014 18:57, Peter Maydell ha scritto:
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
In commit
fc97bb5ba3e7239c0b6d24095df6784868dfebbfthelduw_raw()call was eliminated. But we are reading from the target buffer a 16-bit value, which is in big-endian format. Therefore, swap the bytes if we are building for a little-endian host.Paolo, can you remember why you included this change in that commit? It purports to just be moving the display devices around but it seems to have included the introduction of this bug, and also a removal of a
lduw_raw()call from (what is now)hw/display/blizzard_template.hwhich I suspect is also wrong...
Most likely it was an incorrectly squashed patch.
Paolo
[Qemu-devel] [PULL v4 08/12] target-lm32: add breakpoint/watchpoint support
In reply to Michael WalleThis patch adds in-target breakpoint and watchpoint support.
--- target-lm32/TODO | 2 -- target-lm32/cpu.c | 1 + target-lm32/cpu.h | 27 ++++++++++++-- target-lm32/helper.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ target-lm32/helper.h | 3 ++ target-lm32/op_helper.c | 58 +++++++++++++++++++++++++++++- target-lm32/translate.c | 6 ++-- 7 files changed, 178 insertions(+), 8 deletions(-)
target-lm32/TODO +0 -2
@@ -1,3 +1 @@ -* disassembler (lm32-dis.c) * linux-user emulation -* native bp/wp emulation (?)
target-lm32/cpu.c +1 -0
@@ -153,6 +153,7 @@ static void lm32_cpu_initfn(Object *obj)if (tcg_enabled () && !tcg_initialized) { tcg_initialized = true;lm32_translate_init (); +cpu_set_debug_excp_handler (lm32_debug_excp_handler); } }
target-lm32/cpu.h +25 -2
@@ -163,8 +163,11 @@ struct CPULM32State {/* debug registers */ uint32_t dc;/* debug control */ -uint32_t bp[4 ];/* breakpoint addresses */ -uint32_t wp[4 ];/* watchpoint addresses */ +uint32_t bp[4 ];/* breakpoints */ +uint32_t wp[4 ];/* watchpoints */ + +CPUBreakpoint * cpu_breakpoint[4 ]; +CPUWatchpoint * cpu_watchpoint[4 ];CPU_COMMON
@@ -181,6 +184,19 @@ struct CPULM32State { }; +typedef enum { +LM32_WP_DISABLED =0 , +LM32_WP_READ , +LM32_WP_WRITE , +LM32_WP_READ_WRITE , +}lm32_wp_t ; + +static inline lm32_wp_t lm32_wp_type (uint32_t dc,int idx) +{ +assert (idx <4 ); +return (dc >> (idx+1 )*2 ) &0x3 ; +} +#include "cpu-qom.h" LM32CPU *cpu_lm32_init (const char *cpu_model);
@@ -193,6 +209,13 @@ int cpu_lm32_signal_handler(int host_signum, void *pinfo,void lm32_cpu_list (FILE *f,fprintf_function cpu_fprintf);void lm32_translate_init (void );void cpu_lm32_set_phys_msb_ignore (CPULM32State *env,int value); +void QEMU_NORETURN raise_exception(CPULM32State *env, int index); +void lm32_debug_excp_handler (CPULM32State *env); +void lm32_breakpoint_insert (CPULM32State *env,int index,target_ulong address); +void lm32_breakpoint_remove (CPULM32State *env,int index); +void lm32_watchpoint_insert (CPULM32State *env,int index,target_ulong address, +lm32_wp_t wp_type); +void lm32_watchpoint_remove (CPULM32State *env,int index);static inline CPULM32State *cpu_init (const char *cpu_model) {
target-lm32/helper.c +89 -0
95 lines not on this page · raw message
target-lm32/helper.h +3 -0
@@ -2,6 +2,9 @@ DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_1(hlt, void, env) +DEF_HELPER_3(wcsr_bp, void, env, i32, i32) +DEF_HELPER_3(wcsr_wp, void, env, i32, i32) +DEF_HELPER_2(wcsr_dc, void, env, i32) DEF_HELPER_2(wcsr_im, void, env, i32) DEF_HELPER_2(wcsr_ip, void, env, i32)DEF_HELPER_2 (wcsr_jtx, void, env, i32)
target-lm32/op_helper.c +57 -1
75 lines not on this page · raw message
target-lm32/translate.c +3 -3
@@ -876,7 +876,7 @@ static void dec_wcsr(DisasContext *dc)gen_helper_wcsr_jrx (cpu_env, cpu_R[dc->r1]);break ;case CSR_DC : -tcg_gen_mov_tl (cpu_dc, cpu_R[dc->r1]); +gen_helper_wcsr_dc (cpu_env, cpu_R[dc->r1]);break ;case CSR_BP0 :case CSR_BP1 :
@@ -888,7 +888,7 @@ static void dec_wcsr(DisasContext *dc) "breakpoint #%i is not available\n", no);break ; } -tcg_gen_mov_tl (cpu_bp[no], cpu_R[dc->r1]); +gen_helper_wcsr_bp (cpu_env, cpu_R[dc->r1],tcg_const_i32 (no));break ;case CSR_WP0 :case CSR_WP1 :
@@ -900,7 +900,7 @@ static void dec_wcsr(DisasContext *dc) "watchpoint #%i is not available\n", no);break ; } -tcg_gen_mov_tl (cpu_wp[no], cpu_R[dc->r1]); +gen_helper_wcsr_wp (cpu_env, cpu_R[dc->r1],tcg_const_i32 (no));break ;case CSR_CC :case CSR_CFG :
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PULL v4 08/12] target-lm32: add breakpoint/watchpoint support
Quoted 1 line · Michael Walle
This patch adds in-target breakpoint and watchpoint support.
This looks at least superficially OK, but I'm not really familiar with QEMU's breakpoint/watchpoint support code. RTH: do you want to have a look over this one?
A style point, since I'm not really able to review for much else:
Quoted 11 lines
target-lm32/helper.c +11
-0+void lm32_debug_excp_handler (CPULM32State *env) +{ +CPUBreakpoint *bp; + +if (env->watchpoint_hit) { +if (env->watchpoint_hit->flags &BP_CPU ) { + env->watchpoint_hit =NULL ; +if (check_watchpoints (env)) { +raise_exception (env,EXCP_WATCHPOINT ); + }else { +cpu_resume_from_signal (env,NULL );
target-lm32/helper.c hwaddr lm32_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) · line 137
Quoted 10 lines
target-lm32/helper.c +10
-0+ } + } + }else { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) +if (bp->pc == env->pc) { +if (bp->flags &BP_CPU ) { +raise_exception (env,EXCP_BREAKPOINT ); + } +break ; + }
Braces around the QTAILQ_FOREACH's body, please.
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +}
thanks
-- PMM
Re: [Qemu-devel] [PULL v4 08/12] target-lm32: add breakpoint/watchpoint support
Quoted 3 lines · Peter Maydell
This looks at least superficially OK, but I'm not really familiar with QEMU's breakpoint/watchpoint support code. RTH: do you want to have a look over this one?
It's copied verbatim from the i386 port, missing braces and all. So it certainly passes the sniff test.
r~
Re: [Qemu-devel] [PULL v4 08/12] target-lm32: add breakpoint/watchpoint support
Quoted 7 lines · Richard Henderson
Quoted 3 lines · Peter Maydell
This looks at least superficially OK, but I'm not really familiar with QEMU's breakpoint/watchpoint support code. RTH: do you want to have a look over this one?
It's copied verbatim from the i386 port, missing braces and all. So it certainly passes the sniff test.
That sounds like we ought to be generalising our support code for bp/wp support in targets. Maybe I'll do that if/when I ever implement bp/wp support for ARM :-)
thanks
-- PMM
[Qemu-devel] [PULL v4 09/12] lm32_sys: print test result on stderr
In reply to Michael WalleDo not use qemu_log().
--- hw/misc/lm32_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/lm32_sys.c +1 -1
@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" ); +fprintf (stderr,"TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" );break ;case R_TESTNAME : s->regs[addr] = value;
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PULL v4 09/12] lm32_sys: print test result on stderr
Quoted 12 lines · Michael Walle
Do not use
qemu_log().Signed-off-by Michael Walle <[email protected]>--- hw/misc/lm32_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/lm32_sys.c +0
-0
hw/misc/lm32_sys.c static void sys_write(void *opaque, hwaddr addr, · line 84
Quoted 6 lines
hw/misc/lm32_sys.c +1
-1@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" ); +fprintf (stderr,"TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" );break ;
This looks wrong to me -- devices shouldn't print to stderr, ideally.
thanks
-- PMM
Re: [Qemu-devel] [PULL v4 09/12] lm32_sys: print test result on stderr
Am Samstag, 1. Februar 2014, 19:00:01 schrieb Peter Maydell:
Quoted 19 lines · Michael Walle
Quoted 18 lines
Do not use
qemu_log().Signed-off-by Michael Walle <[email protected]>---
hw/misc/lm32_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/lm32_sys.c +0
-0@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname;
Quoted 7 lines
Quoted 5 lines
hw/misc/lm32_sys.c +1
-1-qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" ); +fprintf (stderr,"TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" );break;This looks wrong to me -- devices shouldn't print to stderr, ideally.
lm32_sys is actually no real device. it is just used for unit testing.
-michael
Re: [Qemu-devel] [PULL v4 09/12] lm32_sys: print test result on stderr
Am 2014-02-01 21:31, schrieb Michael Walle:
Quoted 24 lines
Am Samstag, 1. Februar 2014, 19:00:01 schrieb Peter Maydell:
Quoted 23 lines · Michael Walle
Quoted 22 lines
Do not use
qemu_log().Signed-off-by Michael Walle <[email protected]>---
hw/misc/lm32_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/lm32_sys.c +1
-1@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" ); +fprintf (stderr,"TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" );
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
break;This looks wrong to me -- devices shouldn't print to stderr, ideally.
lm32_sysis actually no real device. it is just used for unit testing.
Hi Peter,
is this ok? or do you have some better idea? ideally, the lm32 target should use semihosting and should print to stdout/stderr itself. but that is not the case atm.
-michael
Re: [Qemu-devel] [PULL v4 09/12] lm32_sys: print test result on stderr
Quoted 34 lines · Michael Walle
Am 2014-02-01 21:31, schrieb Michael Walle:
Quoted 32 lines
Am Samstag, 1. Februar 2014, 19:00:01 schrieb Peter Maydell:
Quoted 29 lines · Michael Walle
Quoted 24 lines
Do not use
qemu_log().Signed-off-by Michael Walle <[email protected]>---
hw/misc/lm32_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/lm32_sys.c +1
-1@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" : "OK"); + fprintf(stderr, "TC %-32s %s\n", testname, (value) ? "FAILED":
"OK");Quoted 1 line
break;This looks wrong to me -- devices shouldn't print to stderr, ideally.
Quoted 8 lines
Quoted 2 lines
lm32_sysis actually no real device. it is just used for unit testing.Hi Peter,
is this ok? or do you have some better idea? ideally, the lm32 target should use semihosting and should print to stdout/stderr itself. but that is not the case atm.
Well, I guess for a testbench only kind of device printing to stderr is OK.
I've just noticed that the device maps itself into the memory map. That's pretty foul. I can see why it does it, but really this thing is bending a lot of the rules.
thanks
-- PMM
Re: [Qemu-devel] [PULL v4 09/12] lm32_sys: print test result on stderr
Am 2014-02-03 23:59, schrieb Peter Maydell:
Quoted 44 lines · Michael Walle
Quoted 34 lines
Am 2014-02-01 21:31, schrieb Michael Walle:
Quoted 32 lines
Am Samstag, 1. Februar 2014, 19:00:01 schrieb Peter Maydell:
Quoted 29 lines · Michael Walle
Quoted 24 lines
Do not use
qemu_log().Signed-off-by Michael Walle <[email protected]>---
hw/misc/lm32_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/lm32_sys.c +1
-1@@ -80,7 +80,7 @@ static void sys_write(void *opaque, hwaddr addr,case R_PASSFAIL : s->regs[addr] = value; testname = (char *)s->testname; -qemu_log ("TC %-32s %s\n" , testname, (value) ?"FAILED" : "OK"); + fprintf(stderr, "TC %-32s %s\n", testname, (value) ? "FAILED":
"OK");Quoted 1 line
break;This looks wrong to me -- devices shouldn't print to stderr, ideally.
Quoted 8 lines
Quoted 2 lines
lm32_sysis actually no real device. it is just used for unit testing.Hi Peter,
is this ok? or do you have some better idea? ideally, the lm32 target should use semihosting and should print to stdout/stderr itself. but that is not the case atm.
Quoted 5 lines
Well, I guess for a testbench only kind of device printing to stderr is OK.
I've just noticed that the device maps itself into the memory map. That's pretty foul. I can see why it does it, but really this thing is bending a lot of the rules.
So if it is ok, i'll leave this patch in this pull request. But i'll also work on the lm32 semihosting so we can get rid of this device entirely.
-michael
[Qemu-devel] [PULL v4 10/12] lm32_sys: dump cpu state if test case fails
In reply to Michael WalleThis will ease debugging the test cases.
--- hw/misc/lm32_sys.c | 3 +++ 1 file changed, 3 insertions(+)
hw/misc/lm32_sys.c +3 -0
@@ -81,6 +81,9 @@ static void sys_write(void *opaque, hwaddr addr, s->regs[addr] = value; testname = (char *)s->testname;fprintf (stderr,"TC %-32s %s\n" , testname, (value) ?"FAILED" :"OK" ); +if (value) { +cpu_dump_state (qemu_get_cpu (0 ), stderr, fprintf,0 ); + }break ;case R_TESTNAME : s->regs[addr] = value;
Signature · 1 line
1.7.10.4
Quoted 6 lines · Michael Walle
Hi Anthony,
this is a pull request for various updates and fixes for the LatticeMico32 target.
Please pull.
Apologies for doing a review pass on this rather than pulling it. However given that most of the patches didn't have reviewed-by tags I gave them a quick eyeball and felt there were enough minor issues there that I would rather err on the side of caution. If you address the issues I'll review a respin of this patch series and I'm happy to apply a pull request once the patches have got review.
thanks
-- PMM
Am Samstag, 1. Februar 2014, 19:21:28 schrieb Peter Maydell:
Quoted 15 lines · Michael Walle
Quoted 6 lines
Hi Anthony,
this is a pull request for various updates and fixes for the LatticeMico32 target.
Please pull.
Apologies for doing a review pass on this rather than pulling it. However given that most of the patches didn't have reviewed-by tags I gave them a quick eyeball and felt there were enough minor issues there that I would rather err on the side of caution. If you address the issues I'll review a respin of this patch series and I'm happy to apply a pull request once the patches have got review.
Quoted 2 lines
thanks
-- PMM
no problem and thanks for the review. i'm happy to post a cleaned up v5 ;)
-michael