Re: [Qemu-devel] [PATCH 06/10] target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported instructions

2016-06-04 Thread Michael Rolnik
switched to qemu_log. it will be removed after a while.

On Sun, Jun 5, 2016 at 1:48 AM, Richard Henderson  wrote:

> On 06/02/2016 01:06 PM, Michael Rolnik wrote:
>
>> +voidhelper_unsupported(
>> +CPUAVRState*env)
>> +{
>> +CPUState   *cs = CPU(avr_env_get_cpu(env));
>> +
>> +cs->exception_index = EXCP_DEBUG;
>> +cpu_dump_state(cs, stderr, fprintf, 0);
>> +cpu_loop_exit(cs);
>> +}
>>
> ...
>
>> +voidhelper_wdr(
>> +CPUAVRState*env)
>> +{
>> +CPUState   *cs = CPU(avr_env_get_cpu(env));
>> +
>> +cs->exception_index = EXCP_DEBUG;
>> +cpu_loop_exit(cs);
>> +}
>>
>
> Surely EXCP_DEBUG isn't the right thing to be using for these.
>
> +target_ulonghelper_inb(
>> +CPUAVRState*env,
>> +uint32_tport)
>> +{
>> +printf("in: io[%02x]\n", port);
>>
>
> No printf.
>
> If you like you can use qemu_log, but for something like this, probably
> the most useful is the tracing infrastructure.  See the trace-events file.
>
>
> r~
>



-- 
Best Regards,
Michael Rolnik


Re: [Qemu-devel] [PATCH 06/10] target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported instructions

2016-06-04 Thread Richard Henderson

On 06/02/2016 01:06 PM, Michael Rolnik wrote:

+voidhelper_unsupported(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_DEBUG;
+cpu_dump_state(cs, stderr, fprintf, 0);
+cpu_loop_exit(cs);
+}

...

+voidhelper_wdr(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_DEBUG;
+cpu_loop_exit(cs);
+}


Surely EXCP_DEBUG isn't the right thing to be using for these.


+target_ulonghelper_inb(
+CPUAVRState*env,
+uint32_tport)
+{
+printf("in: io[%02x]\n", port);


No printf.

If you like you can use qemu_log, but for something like this, probably the 
most useful is the tracing infrastructure.  See the trace-events file.



r~



[Qemu-devel] [PATCH 06/10] target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported instructions

2016-06-02 Thread Michael Rolnik
Signed-off-by: Michael Rolnik 
---
 target-avr/helper.c | 103 
 target-avr/helper.h |   5 +++
 2 files changed, 108 insertions(+)

diff --git a/target-avr/helper.c b/target-avr/helper.c
index ed22b37..450f598 100644
--- a/target-avr/helper.c
+++ b/target-avr/helper.c
@@ -155,6 +155,23 @@ voidtlb_fill(
 
 tlb_set_page_with_attrs(cs, vaddr, paddr, attrs, prot, mmu_idx, page_size);
 }
+voidhelper_sleep(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_HLT;
+cpu_loop_exit(cs);
+}
+voidhelper_unsupported(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_DEBUG;
+cpu_dump_state(cs, stderr, fprintf, 0);
+cpu_loop_exit(cs);
+}
 
 voidhelper_debug(
 CPUAVRState*env)
@@ -165,3 +182,89 @@ voidhelper_debug(
 cpu_loop_exit(cs);
 }
 
+voidhelper_wdr(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_DEBUG;
+cpu_loop_exit(cs);
+}
+
+target_ulonghelper_inb(
+CPUAVRState*env,
+uint32_tport)
+{
+printf("in: io[%02x]\n", port);
+
+switch (port) {
+case0x3b: {
+return  env->rampZ; /*  RAMPZ */
+}
+case0x3d: { /*  SPL */
+return  env->sp & 0x00ff;
+}
+case0x3e: { /*  SPH */
+return  env->sp >> 8;
+}
+case0x3f: { /*  SREG */
+uint8_t sreg;
+sreg=   (env->sregC & 0x01) << 0
+|   (env->sregZ & 0x01) << 1
+|   (env->sregN & 0x01) << 2
+|   (env->sregV & 0x01) << 3
+|   (env->sregS & 0x01) << 4
+|   (env->sregH & 0x01) << 5
+|   (env->sregT & 0x01) << 6
+|   (env->sregI & 0x01) << 7;
+return  sreg;
+}
+}
+return  0;
+}
+
+voidhelper_outb(
+CPUAVRState*env,
+uint32_tport,
+uint32_tdata)
+{
+printf("out:%02x -> io[%02x]\n", data, port);
+
+data&= 0x00ff;
+
+switch (port) {
+case0x04: {
+qemu_irqirq;
+CPUState   *cpu = CPU(avr_env_get_cpu(env));
+irq = qdev_get_gpio_in(DEVICE(cpu), 3);
+qemu_set_irq(irq, 1);
+break;
+}
+case0x3b: {
+env->rampZ  = data & 0x01;  /*  RAMPZ */
+break;
+}
+case0x3d: { /*  SPL */
+if (avr_feature(env, AVR_FEATURE_2_BYTE_SP)) {
+env->sp = (env->sp & 0xff00) | (data);
+}
+break;
+}
+case0x3e: {  /*  SPH */
+env->sp = (env->sp & 0x00ff) | (data << 8);
+break;
+}
+case0x3f: { /*  SREG */
+env->sregC  = (data >> 0) & 0x01;
+env->sregZ  = (data >> 1) & 0x01;
+env->sregN  = (data >> 2) & 0x01;
+env->sregV  = (data >> 3) & 0x01;
+env->sregS  = (data >> 4) & 0x01;
+env->sregH  = (data >> 5) & 0x01;
+env->sregT  = (data >> 6) & 0x01;
+env->sregI  = (data >> 7) & 0x01;
+break;
+}
+}
+}
+
diff --git a/target-avr/helper.h b/target-avr/helper.h
index 017e076..5a08cfd 100644
--- a/target-avr/helper.h
+++ b/target-avr/helper.h
@@ -18,4 +18,9 @@
  * 
  */
 
+DEF_HELPER_1(wdr,   void,   env)
 DEF_HELPER_1(debug, void,   env)
+DEF_HELPER_1(sleep, void,   env)
+DEF_HELPER_1(unsupported,   void,   env)
+DEF_HELPER_3(outb,  void,   env, i32, i32)
+DEF_HELPER_2(inb,   tl, env, i32)
-- 
2.4.9 (Apple Git-60)




[Qemu-devel] [PATCH 06/10] target-avr: adding helpers for IN, OUT, SLEEP, WBR & unsupported instructions

2016-06-02 Thread Michael Rolnik
Signed-off-by: Michael Rolnik 
---
 target-avr/helper.c | 103 
 target-avr/helper.h |   5 +++
 2 files changed, 108 insertions(+)

diff --git a/target-avr/helper.c b/target-avr/helper.c
index ed22b37..450f598 100644
--- a/target-avr/helper.c
+++ b/target-avr/helper.c
@@ -155,6 +155,23 @@ voidtlb_fill(
 
 tlb_set_page_with_attrs(cs, vaddr, paddr, attrs, prot, mmu_idx, page_size);
 }
+voidhelper_sleep(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_HLT;
+cpu_loop_exit(cs);
+}
+voidhelper_unsupported(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_DEBUG;
+cpu_dump_state(cs, stderr, fprintf, 0);
+cpu_loop_exit(cs);
+}
 
 voidhelper_debug(
 CPUAVRState*env)
@@ -165,3 +182,89 @@ voidhelper_debug(
 cpu_loop_exit(cs);
 }
 
+voidhelper_wdr(
+CPUAVRState*env)
+{
+CPUState   *cs = CPU(avr_env_get_cpu(env));
+
+cs->exception_index = EXCP_DEBUG;
+cpu_loop_exit(cs);
+}
+
+target_ulonghelper_inb(
+CPUAVRState*env,
+uint32_tport)
+{
+printf("in: io[%02x]\n", port);
+
+switch (port) {
+case0x3b: {
+return  env->rampZ; /*  RAMPZ */
+}
+case0x3d: { /*  SPL */
+return  env->sp & 0x00ff;
+}
+case0x3e: { /*  SPH */
+return  env->sp >> 8;
+}
+case0x3f: { /*  SREG */
+uint8_t sreg;
+sreg=   (env->sregC & 0x01) << 0
+|   (env->sregZ & 0x01) << 1
+|   (env->sregN & 0x01) << 2
+|   (env->sregV & 0x01) << 3
+|   (env->sregS & 0x01) << 4
+|   (env->sregH & 0x01) << 5
+|   (env->sregT & 0x01) << 6
+|   (env->sregI & 0x01) << 7;
+return  sreg;
+}
+}
+return  0;
+}
+
+voidhelper_outb(
+CPUAVRState*env,
+uint32_tport,
+uint32_tdata)
+{
+printf("out:%02x -> io[%02x]\n", data, port);
+
+data&= 0x00ff;
+
+switch (port) {
+case0x04: {
+qemu_irqirq;
+CPUState   *cpu = CPU(avr_env_get_cpu(env));
+irq = qdev_get_gpio_in(DEVICE(cpu), 3);
+qemu_set_irq(irq, 1);
+break;
+}
+case0x3b: {
+env->rampZ  = data & 0x01;  /*  RAMPZ */
+break;
+}
+case0x3d: { /*  SPL */
+if (avr_feature(env, AVR_FEATURE_2_BYTE_SP)) {
+env->sp = (env->sp & 0xff00) | (data);
+}
+break;
+}
+case0x3e: {  /*  SPH */
+env->sp = (env->sp & 0x00ff) | (data << 8);
+break;
+}
+case0x3f: { /*  SREG */
+env->sregC  = (data >> 0) & 0x01;
+env->sregZ  = (data >> 1) & 0x01;
+env->sregN  = (data >> 2) & 0x01;
+env->sregV  = (data >> 3) & 0x01;
+env->sregS  = (data >> 4) & 0x01;
+env->sregH  = (data >> 5) & 0x01;
+env->sregT  = (data >> 6) & 0x01;
+env->sregI  = (data >> 7) & 0x01;
+break;
+}
+}
+}
+
diff --git a/target-avr/helper.h b/target-avr/helper.h
index 017e076..5a08cfd 100644
--- a/target-avr/helper.h
+++ b/target-avr/helper.h
@@ -18,4 +18,9 @@
  * 
  */
 
+DEF_HELPER_1(wdr,   void,   env)
 DEF_HELPER_1(debug, void,   env)
+DEF_HELPER_1(sleep, void,   env)
+DEF_HELPER_1(unsupported,   void,   env)
+DEF_HELPER_3(outb,  void,   env, i32, i32)
+DEF_HELPER_2(inb,   tl, env, i32)
-- 
2.4.9 (Apple Git-60)