Skip to contentSkip to conversation

*** SUBJECT HERE ***

PATCH In review Guan Xuetao 4 participants 23 messages May 25, 2012 – May 28, 2012 Kbuild

lore
Share & tools
lore
#4 lore raw

PATCH 4/9 unicore32-softmmu: make sure that kernel can access user space

In reply to Guan Xuetao
---
 target-unicore32/translate.c |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)
target-unicore32/translate.c +24 -9
index d76fff0..1f0ba4f 100644
@@ -33,9 +33,16 @@ typedef struct DisasContext {
     int condlabel;
     struct TranslationBlock *tb;
     int singlestep_enabled;
+#ifndef CONFIG_USER_ONLY
+    int user;
+#endif
 } DisasContext;
 
+#ifndef CONFIG_USER_ONLY
+#define IS_USER(s) (s->user)
+#else
 #define IS_USER(s) 1
+#endif
 
 /* These instructions trap after executing, so defer them until after the
    conditional executions state has been updated.  */
@@ -1551,12 +1558,12 @@ static void do_misc(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
 /* load/store I_offset and R_offset */
 static void do_ldst_ir(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
 {
-    unsigned int i;
+    unsigned int mmuindex;
     TCGv tmp;
     TCGv tmp2;
 
     tmp2 = load_reg(s, UCOP_REG_N);
-    i = (IS_USER(s) || (!UCOP_SET_P && UCOP_SET_W));
+    mmuindex = (IS_USER(s) || (!UCOP_SET_P && UCOP_SET_W));
 
     /* immediate */
     if (UCOP_SET_P) {
@@ -1566,17 +1573,17 @@ static void do_ldst_ir(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
     if (UCOP_SET_L) {
         /* load */
         if (UCOP_SET_B) {
-            tmp = gen_ld8u(tmp2, i);
+            tmp = gen_ld8u(tmp2, mmuindex);
         } else {
-            tmp = gen_ld32(tmp2, i);
+            tmp = gen_ld32(tmp2, mmuindex);
         }
     } else {
         /* store */
         tmp = load_reg(s, UCOP_REG_D);
         if (UCOP_SET_B) {
-            gen_st8(tmp, tmp2, i);
+            gen_st8(tmp, tmp2, mmuindex);
         } else {
-            gen_st32(tmp, tmp2, i);
+            gen_st32(tmp, tmp2, mmuindex);
         }
     }
     if (!UCOP_SET_P) {
@@ -1679,7 +1686,7 @@ static void do_ldst_hwsb(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
 /* load/store multiple words */
 static void do_ldst_m(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
 {
-    unsigned int val, i;
+    unsigned int val, i, mmuindex;
     int j, n, reg, user, loaded_base;
     TCGv tmp;
     TCGv tmp2;
@@ -1700,6 +1707,7 @@ static void do_ldst_m(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
         }
     }
 
+    mmuindex = (IS_USER(s) || (!UCOP_SET_P && UCOP_SET_W));
     addr = load_reg(s, UCOP_REG_N);
 
     /* compute total size */
@@ -1744,7 +1752,7 @@ static void do_ldst_m(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
         }
         if (UCOP_SET(i)) {
             if (UCOP_SET_L) { /* load */
-                tmp = gen_ld32(addr, IS_USER(s));
+                tmp = gen_ld32(addr, mmuindex);
                 if (reg == 31) {
                     gen_bx(s, tmp);
                 } else if (user) {
@@ -1772,7 +1780,7 @@ static void do_ldst_m(CPUUniCore32State *env, DisasContext *s, uint32_t insn)
                 } else {
                     tmp = load_reg(s, reg);
                 }
-                gen_st32(tmp, addr, IS_USER(s));
+                gen_st32(tmp, addr, mmuindex);
             }
             j++;
             /* no need to add after the last transfer */
@@ -1953,6 +1961,13 @@ static inline void gen_intermediate_code_internal(CPUUniCore32State *env,
     cpu_F1s = tcg_temp_new_i32();
     cpu_F0d = tcg_temp_new_i64();
     cpu_F1d = tcg_temp_new_i64();
+#ifndef CONFIG_USER_ONLY
+    if ((env->uncached_asr & 0x1f) == 0x10) {
+        dc->user = 1;
+    } else {
+        dc->user = 0;
+    }
+#endif
     next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
     lj = -1;
     num_insns = 0;
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/9 unicore32-softmmu: make exceptions generated in unicore32 architecture

In reply to Guan Xuetao

We need to specify the exception type in proper situations. Then it could make exceptions generated correctly and timely.

---
 cpu-exec.c             |    1 +
 linux-user/main.c      |    3 ++-
 target-unicore32/cpu.h |    6 ++++--
 3 files changed, 7 insertions(+), 3 deletions(-)
cpu-exec.c +1 -0
index 0344cd5..929b535 100644
@@ -416,6 +416,7 @@ int cpu_exec(CPUArchState *env)
 #elif defined(TARGET_UNICORE32)
                     if (interrupt_request & CPU_INTERRUPT_HARD
                         && !(env->uncached_asr & ASR_I)) {
+                        env->exception_index = UC32_EXCP_INTR;
                         do_interrupt(env);
                         next_tb = 0;
                     }
linux-user/main.c +2 -1
index 191b750..a394409 100644
@@ -958,7 +958,8 @@ void cpu_loop(CPUUniCore32State *env)
                 }
             }
             break;
-        case UC32_EXCP_TRAP:
+        case UC32_EXCP_DTRAP:
+        case UC32_EXCP_ITRAP:
             info.si_signo = SIGSEGV;
             info.si_errno = 0;
             /* XXX: check env->error_code */
target-unicore32/cpu.h +4 -2
index 81c14ff..66c42f5 100644
@@ -89,8 +89,10 @@ typedef struct CPUUniCore32State {
 #define ASR_NZCV                (ASR_N | ASR_Z | ASR_C | ASR_V)
 #define ASR_RESERVED            (~(ASR_M | ASR_I | ASR_NZCV))
 
-#define UC32_EXCP_PRIV          (ASR_MODE_PRIV)
-#define UC32_EXCP_TRAP          (ASR_MODE_TRAP)
+#define UC32_EXCP_PRIV          (1)
+#define UC32_EXCP_ITRAP         (2)
+#define UC32_EXCP_DTRAP         (3)
+#define UC32_EXCP_INTR          (4)
 
 /* Return the current ASR value.  */
 target_ulong cpu_asr_read(CPUUniCore32State *env1);
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/9 unicore32-softmmu: implement some softmmu specific functions

In reply to Guan Xuetao

This patch seperates softmmu functions from the old user-only ones. So the full exception handlers and page table walking could work now.

---
 target-unicore32/helper.c       |   25 ++--
 target-unicore32/uc32_softmmu.c |  267 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 280 insertions(+), 12 deletions(-)
 create mode 100644 target-unicore32/uc32_softmmu.c
target-unicore32/helper.c +13 -12
index 9fe4a37..29e5c78 100644
@@ -45,19 +45,27 @@ uint32_t HELPER(clz)(uint32_t x)
     return clz32(x);
 }
 
+#ifdef CONFIG_USER_ONLY
 void do_interrupt(CPUUniCore32State *env)
 {
-    env->exception_index = -1;
+    cpu_abort(env, "NO interrupt in user mode\n");
 }
 
-int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, int rw,
-                              int mmu_idx)
+int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address,
+        int rw, int mmu_idx)
 {
-    env->exception_index = UC32_EXCP_TRAP;
-    env->cp0.c4_faultaddr = address;
+    cpu_abort(env, "NO mmu fault in user mode\n");
     return 1;
 }
 
+void switch_mode(CPUUniCore32State *env, int mode)
+{
+    if (mode != ASR_MODE_USER) {
+        cpu_abort(env, "Tried to switch out of user mode\n");
+    }
+}
+#endif
+
 /* These should probably raise undefined insn exceptions.  */
 void HELPER(set_cp)(CPUUniCore32State *env, uint32_t insn, uint32_t val)
 {
@@ -84,13 +92,6 @@ uint32_t HELPER(get_cp0)(CPUUniCore32State *env, uint32_t insn)
     return 0;
 }
 
-void switch_mode(CPUUniCore32State *env, int mode)
-{
-    if (mode != ASR_MODE_USER) {
-        cpu_abort(env, "Tried to switch out of user mode\n");
-    }
-}
-
 void HELPER(set_r29_banked)(CPUUniCore32State *env, uint32_t mode, uint32_t val)
 {
     cpu_abort(env, "banked r29 write\n");
target-unicore32/uc32_softmmu.c new file +267 -0

267 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 3/9 unicore32-softmmu: add coprocessor 0 and ocd instruction support

In reply to Guan Xuetao

Coprocessor 0 is system control coprocessor, and we need get/set its contents. Also, all cache/tlb ops shoule be implemented here, but just ignored with no harm.

OCD (on-chip-debugger) is used for faked console, so we could output chars to this console without graphic card.

---
 target-unicore32/helper.c    |   37 --------
 target-unicore32/helper.h    |   15 ++--
 target-unicore32/op_helper.c |  187 +++++++++++++++++++++++++++++++++++++++++-
 target-unicore32/translate.c |   73 ++++++++++++++++
 4 files changed, 265 insertions(+), 47 deletions(-)
target-unicore32/helper.c +0 -37
index 29e5c78..a06ebf3 100644
@@ -66,43 +66,6 @@ void switch_mode(CPUUniCore32State *env, int mode)
 }
 #endif
 
-/* These should probably raise undefined insn exceptions.  */
-void HELPER(set_cp)(CPUUniCore32State *env, uint32_t insn, uint32_t val)
-{
-    int op1 = (insn >> 8) & 0xf;
-    cpu_abort(env, "cp%i insn %08x\n", op1, insn);
-    return;
-}
-
-uint32_t HELPER(get_cp)(CPUUniCore32State *env, uint32_t insn)
-{
-    int op1 = (insn >> 8) & 0xf;
-    cpu_abort(env, "cp%i insn %08x\n", op1, insn);
-    return 0;
-}
-
-void HELPER(set_cp0)(CPUUniCore32State *env, uint32_t insn, uint32_t val)
-{
-    cpu_abort(env, "cp0 insn %08x\n", insn);
-}
-
-uint32_t HELPER(get_cp0)(CPUUniCore32State *env, uint32_t insn)
-{
-    cpu_abort(env, "cp0 insn %08x\n", insn);
-    return 0;
-}
-
-void HELPER(set_r29_banked)(CPUUniCore32State *env, uint32_t mode, uint32_t val)
-{
-    cpu_abort(env, "banked r29 write\n");
-}
-
-uint32_t HELPER(get_r29_banked)(CPUUniCore32State *env, uint32_t mode)
-{
-    cpu_abort(env, "banked r29 read\n");
-    return 0;
-}
-
 /* UniCore-F64 support.  We follow the convention used for F64 instrunctions:
    Single precition routines have a "s" suffix, double precision a
    "d" suffix.  */
target-unicore32/helper.h +6 -9
index 5a3b8a4..11c3726 100644
@@ -8,6 +8,12 @@
  */
 #include "def-helper.h"
 
+#ifndef CONFIG_USER_ONLY
+DEF_HELPER_3(cp0_set, void, i32, i32, i32)
+DEF_HELPER_2(cp0_get, i32, i32, i32)
+DEF_HELPER_1(cp1_putc, void, i32)
+#endif
+
 DEF_HELPER_1(clz, i32, i32)
 DEF_HELPER_1(clo, i32, i32)
 
@@ -16,12 +22,6 @@ DEF_HELPER_1(exception, void, i32)
 DEF_HELPER_2(asr_write, void, i32, i32)
 DEF_HELPER_0(asr_read, i32)
 
-DEF_HELPER_3(set_cp0, void, env, i32, i32)
-DEF_HELPER_2(get_cp0, i32, env, i32)
-
-DEF_HELPER_3(set_cp, void, env, i32, i32)
-DEF_HELPER_2(get_cp, i32, env, i32)
-
 DEF_HELPER_1(get_user_reg, i32, i32)
 DEF_HELPER_2(set_user_reg, void, i32, i32)
 
@@ -38,9 +38,6 @@ DEF_HELPER_2(shr_cc, i32, i32, i32)
 DEF_HELPER_2(sar_cc, i32, i32, i32)
 DEF_HELPER_2(ror_cc, i32, i32, i32)
 
-DEF_HELPER_2(get_r29_banked, i32, env, i32)
-DEF_HELPER_3(set_r29_banked, void, env, i32, i32)
-
 DEF_HELPER_1(ucf64_get_fpscr, i32, env)
 DEF_HELPER_2(ucf64_set_fpscr, void, env, i32)
 
target-unicore32/op_helper.c +186 -1

202 lines not on this page · raw message

target-unicore32/translate.c +73 -0

85 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#0 lore raw

cover *** SUBJECT HERE ***

These patches implement softmmu support on unicore32 architecture.

UniCore32 CPU is embedded in PKUnity-3 SoC, so we add hw/pkunity dir to contain all puv3 devices simulation codes together.
Only minimal system control modules are simulated, to make linux kernel boot and busybox run in initramfs.

Any advice is greatly appreciated.

Thanks,

Guan Xuetao

---

Guan Xuetao (9):
unicore32-softmmu: make exceptions generated in unicore32
architecture
unicore32-softmmu: implement some softmmu specific functions
unicore32-softmmu: add coprocessor 0 and ocd instruction support
unicore32-softmmu: make sure that kernel can access user space
unicore32-softmmu: initialize ucv2 cpu
unicore32-softmmu: add generic cpu state save/load functions
unicore32-softmmu: add puv3 soc support
unicore32-softmmu: add config and makefile support
unicore32-softmmu: add maintainer information

 MAINTAINERS                           |    7 +
 Makefile.target                       |    5 +
 arch_init.c                           |    2 +
 arch_init.h                           |    1 +
 configure                             |    4 +
 cpu-exec.c                            |    1 +
 default-configs/unicore32-softmmu.mak |    4 +
 hw/pkunity/puv3.c                     |  130 ++++++++++++++++
 hw/pkunity/puv3.h                     |   49 ++++++
 hw/pkunity/puv3_dma.c                 |  109 +++++++++++++
 hw/pkunity/puv3_gpio.c                |  141 +++++++++++++++++
 hw/pkunity/puv3_intc.c                |  135 +++++++++++++++++
 hw/pkunity/puv3_ost.c                 |  151 +++++++++++++++++++
 hw/pkunity/puv3_pm.c                  |  148 ++++++++++++++++++
 linux-user/main.c                     |    3 +-
 target-unicore32/cpu.c                |   17 ++-
 target-unicore32/cpu.h                |    8 +-
 target-unicore32/helper.c             |   48 +-----
 target-unicore32/helper.h             |   15 +-
 target-unicore32/machine.c            |   99 ++++++++++++
 target-unicore32/op_helper.c          |  187 +++++++++++++++++++++++-
 target-unicore32/translate.c          |  106 ++++++++++++-
 target-unicore32/uc32_softmmu.c       |  267 +++++++++++++++++++++++++++++++++
 23 files changed, 1568 insertions(+), 69 deletions(-)
 create mode 100644 default-configs/unicore32-softmmu.mak
 create mode 100644 hw/pkunity/puv3.c
 create mode 100644 hw/pkunity/puv3.h
 create mode 100644 hw/pkunity/puv3_dma.c
 create mode 100644 hw/pkunity/puv3_gpio.c
 create mode 100644 hw/pkunity/puv3_intc.c
 create mode 100644 hw/pkunity/puv3_ost.c
 create mode 100644 hw/pkunity/puv3_pm.c
 create mode 100644 target-unicore32/machine.c
 create mode 100644 target-unicore32/uc32_softmmu.c
#5 lore raw

PATCH 5/9 unicore32-softmmu: initialize ucv2 cpu

---
 target-unicore32/cpu.c |   17 +++++++++++++----
 target-unicore32/cpu.h |    2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)
target-unicore32/cpu.c +13 -4
index de63f58..62c0a22 100644
@@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
     UniCore32CPU *cpu = UNICORE32_CPU(obj);
     CPUUniCore32State *env = &cpu->env;
 
-    env->cp0.c0_cpuid = 0x40010863;
+    env->cp0.c0_cpuid = UC32_CPUID_UCV2;
+    env->cp0.c0_cachetype = 0x0d152152;
+    env->cp0.c1_sys = 0x2000;
+    env->cp0.c2_base = 0x0;
+    env->cp0.c3_faultstatus = 0x0;
+    env->cp0.c4_faultaddr = 0x0;
+    env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
 
     set_feature(env, UC32_HWCAP_CMOV);
     set_feature(env, UC32_HWCAP_UCF64);
-    env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
-    env->cp0.c0_cachetype = 0x1dd20d2;
-    env->cp0.c1_sys = 0x00090078;
 }
 
 static void uc32_any_cpu_initfn(Object *obj)
@@ -47,6 +50,7 @@ static void uc32_any_cpu_initfn(Object *obj)
     CPUUniCore32State *env = &cpu->env;
 
     env->cp0.c0_cpuid = 0xffffffff;
+    env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
 
     set_feature(env, UC32_HWCAP_CMOV);
     set_feature(env, UC32_HWCAP_UCF64);
@@ -65,8 +69,13 @@ static void uc32_cpu_initfn(Object *obj)
     cpu_exec_init(env);
     env->cpu_model_str = object_get_typename(obj);
 
+#ifdef CONFIG_USER_ONLY
     env->uncached_asr = ASR_MODE_USER;
     env->regs[31] = 0;
+#else
+    env->uncached_asr = ASR_MODE_PRIV;
+    env->regs[31] = 0x03000000;
+#endif
 
     tlb_flush(env, 1);
 }
target-unicore32/cpu.h +1 -1
index 66c42f5..8af3649 100644
@@ -123,7 +123,7 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
 #define UC32_HWCAP_UCF64                8 /* 1 << 3 */
 
 #define UC32_CPUID(env)                 (env->cp0.c0_cpuid)
-#define UC32_CPUID_UCV2                 0x40010863
+#define UC32_CPUID_UCV2                 0x4d000863
 #define UC32_CPUID_ANY                  0xffffffff
 
 #define cpu_init                        uc32_cpu_init
Signature · 1 line
1.7.0.4
#9 lore raw

PATCH 6/9 unicore32-softmmu: add generic cpu state save/load functions

In reply to Guan Xuetao

This patch adds generic cpu state save/load functions for UniCore32 ISA. All architecture related registers are saved or loaded, and no optimization.

---
 target-unicore32/machine.c |   99 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 target-unicore32/machine.c
target-unicore32/machine.c new file +99 -0
new file mode 100644
index 0000000..e8c52cd
@@ -0,0 +1,99 @@
+/*
+ * Generic machine functions for UniCore32 ISA
+ *
+ * Copyright (C) 2010-2012 Guan Xuetao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or any later version.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/hw.h"
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+    int i;
+    CPUUniCore32State *env = (CPUUniCore32State *)opaque;
+
+    for (i = 0; i < 32; i++) {
+        qemu_put_be32(f, env->regs[i]);
+    }
+    qemu_put_be32(f, cpu_asr_read(env));
+    qemu_put_be32(f, env->bsr);
+    for (i = 0; i < 6; i++) {
+        qemu_put_be32(f, env->banked_bsr[i]);
+        qemu_put_be32(f, env->banked_r29[i]);
+        qemu_put_be32(f, env->banked_r30[i]);
+    }
+
+    qemu_put_be32(f, env->cp0.c0_cpuid);
+    qemu_put_be32(f, env->cp0.c0_cachetype);
+    qemu_put_be32(f, env->cp0.c1_sys);
+    qemu_put_be32(f, env->cp0.c2_base);
+    qemu_put_be32(f, env->cp0.c3_faultstatus);
+    qemu_put_be32(f, env->cp0.c4_faultaddr);
+    qemu_put_be32(f, env->cp0.c5_cacheop);
+    qemu_put_be32(f, env->cp0.c6_tlbop);
+
+    qemu_put_be32(f, env->features);
+
+    if (env->features & UC32_HWCAP_UCF64) {
+        for (i = 0;  i < 16; i++) {
+            CPU_DoubleU u;
+            u.d = env->ucf64.regs[i];
+            qemu_put_be32(f, u.l.upper);
+            qemu_put_be32(f, u.l.lower);
+        }
+        for (i = 0; i < 32; i++) {
+            qemu_put_be32(f, env->ucf64.xregs[i]);
+        }
+    }
+}
+
+int cpu_load(QEMUFile *f, void *opaque, int version_id)
+{
+    CPUUniCore32State *env = (CPUUniCore32State *)opaque;
+    int i;
+    uint32_t val;
+
+    if (version_id != CPU_SAVE_VERSION) {
+        return -EINVAL;
+    }
+
+    for (i = 0; i < 32; i++) {
+        env->regs[i] = qemu_get_be32(f);
+    }
+    val = qemu_get_be32(f);
+    /* Avoid mode switch when restoring ASR.  */
+    env->uncached_asr = val & ASR_M;
+    cpu_asr_write(env, val, 0xffffffff);
+    env->bsr = qemu_get_be32(f);
+    for (i = 0; i < 6; i++) {
+        env->banked_bsr[i] = qemu_get_be32(f);
+        env->banked_r29[i] = qemu_get_be32(f);
+        env->banked_r30[i] = qemu_get_be32(f);
+    }
+
+    env->cp0.c0_cpuid = qemu_get_be32(f);
+    env->cp0.c0_cachetype = qemu_get_be32(f);
+    env->cp0.c1_sys = qemu_get_be32(f);
+    env->cp0.c2_base = qemu_get_be32(f);
+    env->cp0.c3_faultstatus = qemu_get_be32(f);
+    env->cp0.c4_faultaddr = qemu_get_be32(f);
+    env->cp0.c5_cacheop = qemu_get_be32(f);
+    env->cp0.c6_tlbop = qemu_get_be32(f);
+
+    if (env->features & UC32_HWCAP_UCF64) {
+        for (i = 0;  i < 16; i++) {
+            CPU_DoubleU u;
+            u.l.upper = qemu_get_be32(f);
+            u.l.lower = qemu_get_be32(f);
+            env->ucf64.regs[i] = u.d;
+        }
+        for (i = 0; i < 16; i++) {
+            env->ucf64.xregs[i] = qemu_get_be32(f);
+        }
+    }
+
+    return 0;
+}
Signature · 1 line
1.7.0.4
#16 lore raw

PATCH 8/9 unicore32-softmmu: add config and makefile support

In reply to Guan Xuetao

This patch adds configure and makefile support for unicore32-softmmu. All puv3-soc devices are put into hw/pkunity directory, so this dir will be added when unicore32-softmmu is selected.

---
 Makefile.target                       |    5 +++++
 arch_init.c                           |    2 ++
 arch_init.h                           |    1 +
 configure                             |    4 ++++
 default-configs/unicore32-softmmu.mak |    4 ++++
 5 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 default-configs/unicore32-softmmu.mak
Makefile.target +5 -0
index 1582904..2f850d3 100644
@@ -387,6 +387,11 @@ obj-xtensa-y += core-dc232b.o
 obj-xtensa-y += core-dc233c.o
 obj-xtensa-y += core-fsf.o
 
+obj-unicore32-y += uc32_softmmu.o
+obj-unicore32-y += pkunity/puv3.o
+obj-unicore32-y += pkunity/puv3_intc.o pkunity/puv3_ost.o pkunity/puv3_gpio.o
+obj-unicore32-y += pkunity/puv3_pm.o pkunity/puv3_dma.o
+
 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
 monitor.o: hmp-commands.h qmp-commands-old.h
arch_init.c +2 -0
index 988adca..9314025 100644
@@ -81,6 +81,8 @@ int graphic_depth = 15;
 #define QEMU_ARCH QEMU_ARCH_SPARC
 #elif defined(TARGET_XTENSA)
 #define QEMU_ARCH QEMU_ARCH_XTENSA
+#elif defined(TARGET_UNICORE32)
+#define QEMU_ARCH QEMU_ARCH_UNICORE32
 #endif
 
 const uint32_t arch_type = QEMU_ARCH;
arch_init.h +1 -0
index c7cb94a..5298139 100644
@@ -16,6 +16,7 @@ enum {
     QEMU_ARCH_SH4 = 1024,
     QEMU_ARCH_SPARC = 2048,
     QEMU_ARCH_XTENSA = 4096,
+    QEMU_ARCH_UNICORE32 = 8192,
 };
 
 extern const uint32_t arch_type;
configure +4 -0
index b55a792..e4a7c3a 100755
@@ -934,6 +934,7 @@ sparc64-softmmu \
 s390x-softmmu \
 xtensa-softmmu \
 xtensaeb-softmmu \
+unicore32-softmmu \
 "
 fi
 # the following are Linux specific
@@ -3504,6 +3505,9 @@ mkdir -p $target_dir/kvm
 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
   mkdir -p $target_dir/nwfpe
 fi
+if test "$target" = "unicore32-softmmu" ; then
+  mkdir -p $target_dir/pkunity
+fi
 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
 
 
default-configs/unicore32-softmmu.mak new file +4 -0
new file mode 100644
index 0000000..7508f75
@@ -0,0 +1,4 @@
+# Default configuration for unicore32-softmmu
+
+CONFIG_PTIMER=y
+CONFIG_PCKBD=y
Signature · 1 line
1.7.0.4
#20 lore raw

PATCH 9/9 unicore32-softmmu: add maintainer information

In reply to Guan Xuetao
---
 MAINTAINERS |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
index b45f075..5b6b031 100644
@@ -394,6 +394,13 @@ M: Alexander Graf <[email protected]>
 S: Maintained
 F: hw/s390-*.c
 
+UniCore32 Machines
+-------------
+PKUnity-3 SoC initramfs-with-busybox
+M: Guan Xuetao <[email protected]>
+S: Maintained
+F: hw/pkunity/
+
 X86 Machines
 ------------
 PC
Signature · 1 line
1.7.0.4
#13 lore raw

PATCH 7/9 unicore32-softmmu: add puv3 soc support

In reply to Guan Xuetao

This patch only add minimal necessary system-control modules simulation for successfully kernel booting and busybox running.

---
 hw/pkunity/puv3.c      |  130 +++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3.h      |   49 ++++++++++++++++
 hw/pkunity/puv3_dma.c  |  109 ++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_gpio.c |  141 ++++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_intc.c |  135 ++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_ost.c  |  151 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_pm.c   |  148 +++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 863 insertions(+), 0 deletions(-)
 create mode 100644 hw/pkunity/puv3.c
 create mode 100644 hw/pkunity/puv3.h
 create mode 100644 hw/pkunity/puv3_dma.c
 create mode 100644 hw/pkunity/puv3_gpio.c
 create mode 100644 hw/pkunity/puv3_intc.c
 create mode 100644 hw/pkunity/puv3_ost.c
 create mode 100644 hw/pkunity/puv3_pm.c
hw/pkunity/puv3.c new file +130 -0
new file mode 100644
index 0000000..2e18f71
@@ -0,0 +1,130 @@
+/*
+ * Generic PKUnity SoC machine and board descriptor
+ *
+ * Copyright (C) 2010-2012 Guan Xuetao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or any later version.
+ * See the COPYING file in the top-level directory.
+ */
+#include "console.h"
+#include "elf.h"
+#include "exec-memory.h"
+#include "../sysbus.h"
+#include "../boards.h"
+#include "../loader.h"
+#include "../pc.h"
+
+#undef DEBUG_PUV3
+#include "puv3.h"
+
+#define KERNEL_LOAD_ADDR        0x03000000
+#define KERNEL_MAX_SIZE         0x00800000 /* Just a guess */
+
+static void puv3_intc_cpu_handler(void *opaque, int irq, int level)
+{
+    CPUUniCore32State *env = (CPUUniCore32State *)opaque;
+
+    assert(irq == 0);
+    if (level) {
+        cpu_interrupt(env, CPU_INTERRUPT_HARD);
+    } else {
+        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+    }
+}
+
+static void puv3_soc_init(CPUUniCore32State *env)
+{
+    qemu_irq *cpu_intc, irqs[PUV3_IRQS_NR];
+    DeviceState *dev;
+    MemoryRegion *i8042 = g_new(MemoryRegion, 1);
+    int i;
+
+    /* Initialize interrupt controller */
+    cpu_intc = qemu_allocate_irqs(puv3_intc_cpu_handler, env, 1);
+    dev = sysbus_create_simple("puv3_intc", PUV3_INTC_BASE, *cpu_intc);
+    for (i = 0; i < PUV3_IRQS_NR; i++) {
+        irqs[i] = qdev_get_gpio_in(dev, i);
+    }
+
+    /* Initialize minimal necessary devices for kernel booting */
+    sysbus_create_simple("puv3_pm", PUV3_PM_BASE, NULL);
+    sysbus_create_simple("puv3_dma", PUV3_DMA_BASE, NULL);
+    sysbus_create_simple("puv3_ost", PUV3_OST_BASE, irqs[PUV3_IRQS_OST0]);
+    sysbus_create_varargs("puv3_gpio", PUV3_GPIO_BASE,
+            irqs[PUV3_IRQS_GPIOLOW0], irqs[PUV3_IRQS_GPIOLOW1],
+            irqs[PUV3_IRQS_GPIOLOW2], irqs[PUV3_IRQS_GPIOLOW3],
+            irqs[PUV3_IRQS_GPIOLOW4], irqs[PUV3_IRQS_GPIOLOW5],
+            irqs[PUV3_IRQS_GPIOLOW6], irqs[PUV3_IRQS_GPIOLOW7],
+            irqs[PUV3_IRQS_GPIOHIGH], NULL);
+
+    /* Keyboard (i8042), mouse disabled for nographic */
+    i8042_mm_init(irqs[PUV3_IRQS_PS2_KBD], NULL, i8042, PUV3_REGS_OFFSET, 4);
+    memory_region_add_subregion(get_system_memory(), PUV3_PS2_BASE, i8042);
+}
+
+static void puv3_board_init(CPUUniCore32State *env, ram_addr_t ram_size)
+{
+    MemoryRegion *ram_memory = g_new(MemoryRegion, 1);
+
+    /* SDRAM at address zero.  */
+    memory_region_init_ram(ram_memory, "puv3.ram", ram_size);
+    vmstate_register_ram_global(ram_memory);
+    memory_region_add_subregion(get_system_memory(), 0, ram_memory);
+}
+
+static void puv3_load_kernel(const char *kernel_filename)
+{
+    int size;
+
+    assert(kernel_filename != NULL);
+
+    /* only zImage format supported */
+    size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
+            KERNEL_MAX_SIZE);
+    if (size < 0) {
+        hw_error("Load kernel error: '%s'\n", kernel_filename);
+    }
+
+    /* cheat curses that we have a graphic console, only under ocd console */
+    graphic_console_init(NULL, NULL, NULL, NULL, NULL);
+}
+
+static void puv3_init(ram_addr_t ram_size, const char *boot_device,
+                     const char *kernel_filename, const char *kernel_cmdline,
+                     const char *initrd_filename, const char *cpu_model)
+{
+    CPUUniCore32State *env;
+
+    if (initrd_filename) {
+        hw_error("Please use kernel built-in initramdisk.\n");
+    }
+
+    if (!cpu_model) {
+        cpu_model = "UniCore-II";
+    }
+
+    env = cpu_init(cpu_model);
+    if (!env) {
+        hw_error("Unable to find CPU definition\n");
+    }
+
+    puv3_soc_init(env);
+    puv3_board_init(env, ram_size);
+    puv3_load_kernel(kernel_filename);
+}
+
+static QEMUMachine puv3_machine = {
+    .name = "puv3",
+    .desc = "PKUnity Version-3 based on UniCore32",
+    .init = puv3_init,
+    .use_scsi = 0,
+};
+
+static void puv3_machine_init(void)
+{
+    qemu_register_machine(&puv3_machine);
+}
+
+machine_init(puv3_machine_init);
hw/pkunity/puv3.h new file +49 -0

49 lines not on this page · raw message

hw/pkunity/puv3_dma.c new file +109 -0

109 lines not on this page · raw message

hw/pkunity/puv3_gpio.c new file +141 -0

141 lines not on this page · raw message

hw/pkunity/puv3_intc.c new file +135 -0

135 lines not on this page · raw message

hw/pkunity/puv3_ost.c new file +151 -0

151 lines not on this page · raw message

hw/pkunity/puv3_pm.c new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#21 lore raw
In reply to Guan Xuetao
Quoted 1 line · Guan Xuetao

These patches implement softmmu support on unicore32 architecture.

I'm really sorry for the subject.

The subject is: softmmu implementation on UniCore32 ISA

Thanks.

Guan Xuetao

#6 lore raw

Re: [Qemu-devel] [PATCH 5/9] unicore32-softmmu: initialize ucv2 cpu

In reply to Guan Xuetao

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 11 lines
---
 target-unicore32/cpu.c |   17 +++++++++++++----
 target-unicore32/cpu.h |    2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)
target-unicore32/cpu.c +0 -0
index de63f58..62c0a22 100644

target-unicore32/cpu.c static void unicore_ii_cpu_initfn(Object *obj) · line 35

Quoted 5 lines
target-unicore32/cpu.c +1 -1
@@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
     UniCore32CPU *cpu = UNICORE32_CPU(obj);
     CPUUniCore32State *env = &cpu->env;
 
-    env->cp0.c0_cpuid = 0x40010863;
+    env->cp0.c0_cpuid = UC32_CPUID_UCV2;

Please don't revert this change. I'll send you the patch to drop the CPUID #defines instead.

Andreas

Quoted 13 lines
target-unicore32/cpu.h +1 -1
index 66c42f5..8af3649 100644
@@ -123,7 +123,7 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
 #define UC32_HWCAP_UCF64                8 /* 1 << 3 */
 
 #define UC32_CPUID(env)                 (env->cp0.c0_cpuid)
-#define UC32_CPUID_UCV2                 0x40010863
+#define UC32_CPUID_UCV2                 0x4d000863
 #define UC32_CPUID_ANY                  0xffffffff
 
 #define cpu_init                        uc32_cpu_init
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#10 lore raw

Re: [Qemu-devel] [PATCH 6/9] unicore32-softmmu: add generic cpu state save/load functions

In reply to Guan Xuetao

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 27 lines

This patch adds generic cpu state save/load functions for UniCore32 ISA. All architecture related registers are saved or loaded, and no optimization.

---
 target-unicore32/machine.c |   99 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 target-unicore32/machine.c
target-unicore32/machine.c new file +12 -0
new file mode 100644
index 0000000..e8c52cd
@@ -0,0 +1,99 @@
+/*
+ * Generic machine functions for UniCore32 ISA
+ *
+ * Copyright (C) 2010-2012 Guan Xuetao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or any later version.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/hw.h"
+

target-unicore32/machine.c line 22

Quoted 10 lines
target-unicore32/machine.c new file +10 -0
+void cpu_save(QEMUFile *f, void *opaque)
+{
+    int i;
+    CPUUniCore32State *env = (CPUUniCore32State *)opaque;
+
+    for (i = 0; i < 32; i++) {
+        qemu_put_be32(f, env->regs[i]);
+    }
+    qemu_put_be32(f, cpu_asr_read(env));
+    qemu_put_be32(f, env->bsr);

[snip]

Please use VMState instead.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#12 lore raw

Re: [Qemu-devel] [PATCH 6/9] unicore32-softmmu: add generic cpu state save/load functions

In reply to Guan Xuetao

Hi Guan,

Quoted 29 lines
target-unicore32/machine.c new file +29 -0
+void cpu_save(QEMUFile *f, void *opaque)
+{
+    int i;
+    CPUUniCore32State *env = (CPUUniCore32State *)opaque;
+
+    for (i = 0; i < 32; i++) {
+        qemu_put_be32(f, env->regs[i]);
+    }
+    qemu_put_be32(f, cpu_asr_read(env));
+    qemu_put_be32(f, env->bsr);
+    for (i = 0; i < 6; i++) {
+        qemu_put_be32(f, env->banked_bsr[i]);
+        qemu_put_be32(f, env->banked_r29[i]);
+        qemu_put_be32(f, env->banked_r30[i]);
+    }
+
+    qemu_put_be32(f, env->cp0.c0_cpuid);
+    qemu_put_be32(f, env->cp0.c0_cachetype);
+    qemu_put_be32(f, env->cp0.c1_sys);
+    qemu_put_be32(f, env->cp0.c2_base);
+    qemu_put_be32(f, env->cp0.c3_faultstatus);
+    qemu_put_be32(f, env->cp0.c4_faultaddr);
+    qemu_put_be32(f, env->cp0.c5_cacheop);
+    qemu_put_be32(f, env->cp0.c6_tlbop);
+
+    qemu_put_be32(f, env->features);
+
+    if (env->features & UC32_HWCAP_UCF64) {
+        for (i = 0;  i < 16; i++) {

target-unicore32/machine.c line 51

Quoted 10 lines
target-unicore32/machine.c new file +10 -0
+            CPU_DoubleU u;
+            u.d = env->ucf64.regs[i];
+            qemu_put_be32(f, u.l.upper);
+            qemu_put_be32(f, u.l.lower);
+        }
+        for (i = 0; i < 32; i++) {
+            qemu_put_be32(f, env->ucf64.xregs[i]);
+        }
+    }
+}

Do you think use VMState rather then QEMUFile is a good idea?
I saw OpenRISC target got this kind of feedback before [1].

Regards,
chenwj

[1] http://lists.gnu.org/archive/html/qemu-devel/2012-05/msg02457.html

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
#14 lore raw

Re: [Qemu-devel] [PATCH 7/9] unicore32-softmmu: add puv3 soc support

In reply to Guan Xuetao

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 4 lines

This patch only add minimal necessary system-control modules simulation for successfully kernel booting and busybox running.

Quoted 16 lines
---
 hw/pkunity/puv3.c      |  130 +++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3.h      |   49 ++++++++++++++++
 hw/pkunity/puv3_dma.c  |  109 ++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_gpio.c |  141 ++++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_intc.c |  135 ++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_ost.c  |  151 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_pm.c   |  148 +++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 863 insertions(+), 0 deletions(-)
 create mode 100644 hw/pkunity/puv3.c
 create mode 100644 hw/pkunity/puv3.h
 create mode 100644 hw/pkunity/puv3_dma.c
 create mode 100644 hw/pkunity/puv3_gpio.c
 create mode 100644 hw/pkunity/puv3_intc.c
 create mode 100644 hw/pkunity/puv3_ost.c
 create mode 100644 hw/pkunity/puv3_pm.c

Added a subdirectory without adapting configure and possibly Makefiles will break out-of-tree builds. Can't you just name the files puv3_something.[ch] as done for other SoCs?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#17 lore raw

Re: [Qemu-devel] [PATCH 8/9] unicore32-softmmu: add config and makefile support

In reply to Guan Xuetao

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 19 lines

This patch adds configure and makefile support for unicore32-softmmu. All puv3-soc devices are put into hw/pkunity directory, so this dir will be added when unicore32-softmmu is selected.

---
 Makefile.target                       |    5 +++++
 arch_init.c                           |    2 ++
 arch_init.h                           |    1 +
 configure                             |    4 ++++
 default-configs/unicore32-softmmu.mak |    4 ++++
 5 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 default-configs/unicore32-softmmu.mak
Makefile.target +0 -0
index 1582904..2f850d3 100644

Makefile.target obj-xtensa-y += core-dc232b.o · line 393

Quoted 7 lines
Makefile.target +4 -0
@@ -387,6 +387,11 @@ obj-xtensa-y += core-dc232b.o
 obj-xtensa-y += core-dc233c.o
 obj-xtensa-y += core-fsf.o
 
+obj-unicore32-y += uc32_softmmu.o
+obj-unicore32-y += pkunity/puv3.o
+obj-unicore32-y += pkunity/puv3_intc.o pkunity/puv3_ost.o pkunity/puv3_gpio.o
+obj-unicore32-y += pkunity/puv3_pm.o pkunity/puv3_dma.o

[snip]

You need to put the Makefile/configure changes into the patches that introduce the files please, otherwise they cannot be checked for compiler warnings/errors.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#22 lore raw
In reply to Guan Xuetao

Hello Xuetao,

Am 25.05.2012 13:28, schrieb Guan Xuetao:

Quoted 1 line
 target-unicore32/op_helper.c          |  187 +++++++++++++++++++++++-

Your patches add new code to op_helper.c, whereas for other architectures there's work going on to drop old-style op_helper.c (examples committed are sparc and alpha; ppc and x86 are on the list). Maybe you want to consider that at least for the new helpers you're introducing?

In master I noticed that reset was not implemented for unicore32. Haven't seen whether that is being implemented somewhere in this series?

You don't indicate what this series is based on so I assume master and would ask you to rebase onto qom-next branch, which is going to be the basis for 1.2 (in particular no cpu_state_reset() any more).

Please update cpu_uc32_init() to return UniCore32CPU so that you can use it in puv3_init() in place of cpu_init(). See cpu_arm_init()/cpu_init() on master or many more examples on qom-next.
Your static helpers should also prefer to pass around UniCore32CPU *cpu rather than CPUUniCore32State *env, as my recent patch series starts moving code out of env and into the CPUState base class.

Some general notes:
* machine_init() declares a function, so does not need a semicolon.
* TypeInfo when immutable (the regular case) should be static const.
* Struct type names should be CamelCase, not _t.

Any chance to split up patch 7 further for review?

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw

Re: [Qemu-devel] [PATCH 5/9] unicore32-softmmu: initialize ucv2 cpu

In reply to Andreas Färber
Quoted 15 lines

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 14 lines
---
 target-unicore32/cpu.c |   17 +++++++++++++----
 target-unicore32/cpu.h |    2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)
target-unicore32/cpu.c +0 -0
index de63f58..62c0a22 100644
@@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
     UniCore32CPU *cpu = UNICORE32_CPU(obj);
     CPUUniCore32State *env = &cpu->env;
 
Quoted 5 lines

target-unicore32/cpu.c static void unicore_ii_cpu_initfn(Object *obj) · line 35

Quoted 2 lines
target-unicore32/cpu.c +1 -1
-    env->cp0.c0_cpuid = 0x40010863;
+    env->cp0.c0_cpuid = UC32_CPUID_UCV2;

Please don't revert this change. I'll send you the patch to drop the CPUID #defines instead.

But, the kernel need this CPUID to check whether it is a unicore32 processor, and if check fail, the kernel will halt.

Guan Xuetao

#11 lore raw

Re: [Qemu-devel] [PATCH 6/9] unicore32-softmmu: add generic cpu state save/load functions

In reply to Andreas Färber
Quoted 42 lines

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 39 lines

This patch adds generic cpu state save/load functions for UniCore32 ISA. All architecture related registers are saved or loaded, and no optimization.

---
 target-unicore32/machine.c |   99
++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 target-unicore32/machine.c
target-unicore32/machine.c new file +22 -0
new file mode 100644
index 0000000..e8c52cd
@@ -0,0 +1,99 @@
+/*
+ * Generic machine functions for UniCore32 ISA
+ *
+ * Copyright (C) 2010-2012 Guan Xuetao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or any later version.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/hw.h"
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+    int i;
+    CPUUniCore32State *env = (CPUUniCore32State *)opaque;
+
+    for (i = 0; i < 32; i++) {
+        qemu_put_be32(f, env->regs[i]);
+    }
+    qemu_put_be32(f, cpu_asr_read(env));
+    qemu_put_be32(f, env->bsr);

[snip]

Quoted 3 lines

Please use VMState instead.

Andreas

Thanks, I will try it.

Guan Xuetao

#15 lore raw

Re: [Qemu-devel] [PATCH 7/9] unicore32-softmmu: add puv3 soc support

In reply to Andreas Färber
Quoted 26 lines

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 16 lines

This patch only add minimal necessary system-control modules simulation for successfully kernel booting and busybox running.

---
 hw/pkunity/puv3.c      |  130 +++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3.h      |   49 ++++++++++++++++
 hw/pkunity/puv3_dma.c  |  109 ++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_gpio.c |  141
++++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_intc.c |  135
++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_ost.c  |  151
++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pkunity/puv3_pm.c   |  148

+++++++++++++++++++++++++++++++++++++++++++++++

Quoted 8 lines
 7 files changed, 863 insertions(+), 0 deletions(-)
 create mode 100644 hw/pkunity/puv3.c
 create mode 100644 hw/pkunity/puv3.h
 create mode 100644 hw/pkunity/puv3_dma.c
 create mode 100644 hw/pkunity/puv3_gpio.c
 create mode 100644 hw/pkunity/puv3_intc.c
 create mode 100644 hw/pkunity/puv3_ost.c
 create mode 100644 hw/pkunity/puv3_pm.c
Quoted 6 lines

Added a subdirectory without adapting configure and possibly Makefiles will break out-of-tree builds. Can't you just name the files puv3_something.[ch] as done for other SoCs?

Andreas

Every time, when I 'ls' the source tree of qemu or qemu/hw, it will generate a terrible and over-one-screen output. So, I think a new subdirectory makes it more clear (well-organized) and effective.

Guan Xuetao

#18 lore raw

Re: [Qemu-devel] [PATCH 8/9] unicore32-softmmu: add config and makefile support

In reply to Andreas Färber
Quoted 30 lines

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 27 lines

This patch adds configure and makefile support for unicore32-softmmu. All puv3-soc devices are put into hw/pkunity directory, so this dir will be added when unicore32-softmmu is selected.

---
 Makefile.target                       |    5 +++++
 arch_init.c                           |    2 ++
 arch_init.h                           |    1 +
 configure                             |    4 ++++
 default-configs/unicore32-softmmu.mak |    4 ++++
 5 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 default-configs/unicore32-softmmu.mak
Makefile.target +3 -0
index 1582904..2f850d3 100644
@@ -387,6 +387,11 @@ obj-xtensa-y += core-dc232b.o
 obj-xtensa-y += core-dc233c.o
 obj-xtensa-y += core-fsf.o
 
+obj-unicore32-y += uc32_softmmu.o
+obj-unicore32-y += pkunity/puv3.o
+obj-unicore32-y += pkunity/puv3_intc.o pkunity/puv3_ost.o

pkunity/puv3_gpio.o
+obj-unicore32-y += pkunity/puv3_pm.o pkunity/puv3_dma.o

[snip]

Quoted 5 lines

You need to put the Makefile/configure changes into the patches that introduce the files please, otherwise they cannot be checked for compiler warnings/errors.

Andreas

I think the patch series is considered as a whole, and only compiling/building one device sim-code doesn't make sense. In fact, when unicore32-softmmu not enabled, the device sim-code isn't going to be compiled at all.

Guan Xuetao

#8 lore raw

Re: [Qemu-devel] [PATCH 5/9] unicore32-softmmu: initialize ucv2 cpu

In reply to [email protected]

Am 28.05.2012 11:43, schrieb [email protected]:

Quoted 15 lines
Quoted 15 lines

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 14 lines
---
 target-unicore32/cpu.c |   17 +++++++++++++----
 target-unicore32/cpu.h |    2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)
target-unicore32/cpu.c +0 -0
index de63f58..62c0a22 100644
@@ -32,13 +32,16 @@ static void unicore_ii_cpu_initfn(Object *obj)
     UniCore32CPU *cpu = UNICORE32_CPU(obj);
     CPUUniCore32State *env = &cpu->env;
 
Quoted 8 lines
Quoted 5 lines

target-unicore32/cpu.c static void unicore_ii_cpu_initfn(Object *obj) · line 35

Quoted 2 lines
target-unicore32/cpu.c +1 -1
-    env->cp0.c0_cpuid = 0x40010863;
+    env->cp0.c0_cpuid = UC32_CPUID_UCV2;

Please don't revert this change. I'll send you the patch to drop the CPUID #defines instead.

But, the kernel need this CPUID to check whether it is a unicore32 processor, and if check fail, the kernel will halt.

I'm not discussing about a guest kernel but about your source change
above: The UC32_CPUID_UC32 #define should go away, i.e. please ack (today, if we want it in 1.1) and prepend my patch, and if the value is wrong here it should be changed *here* and not in UC32_CPUID_UCV2.

If you're introducing new uses of UC32_CPUID_UCV2 elsewhere (e.g., for register behavior) then that is a design fault and needs to be fixed. Compare the copro series for target-arm, which gets rid of the CPUID-based switches there.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#19 lore raw

Re: [Qemu-devel] [PATCH 8/9] unicore32-softmmu: add config and makefile support

In reply to [email protected]

Am 28.05.2012 12:08, schrieb [email protected]:

Quoted 30 lines
Quoted 30 lines

Am 25.05.2012 13:29, schrieb Guan Xuetao:

Quoted 27 lines

This patch adds configure and makefile support for unicore32-softmmu. All puv3-soc devices are put into hw/pkunity directory, so this dir will be added when unicore32-softmmu is selected.

---
 Makefile.target                       |    5 +++++
 arch_init.c                           |    2 ++
 arch_init.h                           |    1 +
 configure                             |    4 ++++
 default-configs/unicore32-softmmu.mak |    4 ++++
 5 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 default-configs/unicore32-softmmu.mak
Makefile.target +3 -0
index 1582904..2f850d3 100644
@@ -387,6 +387,11 @@ obj-xtensa-y += core-dc232b.o
 obj-xtensa-y += core-dc233c.o
 obj-xtensa-y += core-fsf.o
 
+obj-unicore32-y += uc32_softmmu.o
+obj-unicore32-y += pkunity/puv3.o
+obj-unicore32-y += pkunity/puv3_intc.o pkunity/puv3_ost.o

pkunity/puv3_gpio.o
+obj-unicore32-y += pkunity/puv3_pm.o pkunity/puv3_dma.o

[snip]

Quoted 8 lines
Quoted 4 lines

You need to put the Makefile/configure changes into the patches that introduce the files please, otherwise they cannot be checked for compiler warnings/errors.

I think the patch series is considered as a whole, and only compiling/building one device sim-code doesn't make sense. In fact, when unicore32-softmmu not enabled, the device sim-code isn't going to be compiled at all.

Well, we expect each patch in a series to build warning-free for bisectability (even if applied in one PULL), and only compiling things in the final patch does not help. The series should be ordered so that we can either manually enable it with --target-list=unicore32-softmmu until it finally gets enabled by default, or like the openrisc target enables itself by default with some stubs and refines itself over the next patches.

The other aspect is to make it easy for humans to review your patches before they can get applied, and personally I find it easier to review small patches. But opinions are divided on that. The criteria for acceptance is not just whether your kernel works in the end [*], my concern is more about how its design aligns with upstream trends like QOM awareness.

Another thing: It is advisable to place SoC devices (as opposed to the machine) into Makefile.objs (hw-unicore32-y) so that they get compiled into libhw32 rather than into the target's directory. That avoids duplicates when a second endianness or a 64-bit version is introduced. (Yes, some existing targets violate that principle. I am working towards fixing it.)

Andreas

[*] It would be helpful if you could share linux-user and softmmu binaries on the Wiki for us to avoid regressions.
http://wiki.qemu.org/Testing

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg